Project 1
Spring 2023
Due: W 2/8 @ 5 PM
6 points
In this project, you will use classes and object composition to implement software that synchronizes events of a calendar between a device and a cloud server, such as between an iPhone and an iCloud account. I have produced a design document for the classes and methods you need to implement for this project.
To simulate aspects of a real application, the main function should take two file stems from the command line, create names for two input files, read the calendar events from those files, synchronize the events in the two calendars, construct names for two output files, and write the synchronized set of events to the two output files. The main function should catch invalid_argument, logic_error, and unknown exceptions, and output an appropriate message for each.
Since we're faking this (i.e., not implementing on real devices with real calendars), input files will have the extension .in and output files will have the extension .out. For example, the command
cs-class% a.out iphone icloudshould read the events in the files iphone.in and icloud.in, synchronize the events, and write the synchronized events to iphone.out and icloud.out.
The data format for these files consists of seven tab-separated fields:
A 93B3FFC2-CC21-4457-918E-C04E4D9BFB6F "Panel" "ICC Aud" 10/01/09 10:00 AM 10/01/09 01:00 PM 11/11/09 03:28 PM A 851B0018-6AA7-4480-9F00-D85BB858C5BE "Ben" "" 10/01/09 04:15 PM 10/01/09 05:30 PM 11/11/09 03:28 PM
Note that this specifies the internal data format for the application. It is not a data format that a user will see. There is also an external data format that we use to present information to the user. For example, if the application were to print the first event, it should appear as follows:
Name: Panel Location: ICC Aud Start: 10/01/09 10:00 AM End: 10/01/09 01:00 PMNotice that the user can not see the unique identifier or the last date the event was modified, nor do they see the double quotes that delimit the event's name and location. The documentation gives further details for the external data format.
Steps for Development
I prefer bottom-up development over top-down development, but this choice is up to you. With bottom-up development, one starts implementing the class that everything else builds upon or depends upon. In order to implement Calendar, one needs the Event class. In order to implement Event, one needs the DateTime class.
Therefore, the first thing I would implement is the DateTime class, which the application uses to store and manipulate the start, end, and modification dates and times for events. The set methods must perform data-integrity checks and should throw an appropriate exception without modifying corresponding private data member's current value. (Don't worry about the contents of the input stream.)
In addition to providing methods for reading and writing DateTime objects to and from streams, you will also need to overload the equality and relational operators so you can determine if two dates are equal or if one date occurs before another. Implement this class completely and thoroughly test it before implementing the next class. You might find the screencasts and video lectures on the class Web page helpful.
After you have implemented the DateTime class, turn your attention to the Event class, which consists of a status, an event identifier, a name, a location, a start time, an end time, and a modification time, as described previously. In addition to methods for reading and writing to and from streams, you will need to overload the equality and relational operators. The equality operators should determine if two events are equal based on their unique identifiers. The relational operators should determine if one event is earlier or later than some other. Implement this class completely and thoroughly test it before implementing the next class.
Finally, implement the Calendar class, which is simply a vector of Event objects. In addition to methods for reading and writing events of a calendar to and from streams, the primary methods of the class synchronize the events of two calendars based on their modification dates. New events in one calendar should be copied to the other. Events modified in one calendar should be updated in the other. Finally, events deleted on one device should be deleted on the other. However, the delete operation in this case changes the status, but does not physically remove the record, which is necessary for synchronizing events across multiple devices. We'll talk about this further in lecture.
Getting Started
Although you may use any development environment for your project, it must compile and execute on cs-class-1 (i.e., class-1.cs.georgetown.edu). Informally, we will refer to this machine as “cs-class”. Make sure it compiles and runs without error on cs-class before submitting to Autolab. If it runs for you on cs-class, but fails to compile or execute on Autolab, then it means that your testing was not thorough enough.
For convenience, I placed a zip file on cs-class that contains files to help get you started. To retrieve and unpack the zip file, type:
cs-class% cd cs-class% cp ~maloofm/cosc052/p1.zip ./ cs-class% unzip p1.zip cs-class% ls p1/ cs-class% cd p1 cs-class% ls calendar.cpp datetime.cpp event.cpp icloud.in LICENSE main.h calendar.h datetime.h event.h iphone.in main.cpp Makefile cs-class% cd .. cs-class% ls p1.zip p1/ cs-class% rm p1.zipThese commands ensure that you are in your top-level directory (cd), copies the zip file from my directory, unzips the archive, descends into the p1 directory, and lists the files in that subdirectory. The last three commands change the directory to the parent directory, lists the files of the directory, and removes the zip file.
In the p1 directory, there is a Makefile and .cpp and .h files for the project. The files iphone.in and icloud.in contain real events from my calendar, mainly so you can see what an exciting life I lead.
Although these files contain real events, instead of using these during the initial stages of development, I recommend creating your own data files in a simplified, minimal format. I also recommend creating a number of small data files for testing specific synchronization cases. For example, to test for the addition of a new event, create one data file containing two events, and then create another data file with those same events and one additional one. This will let you focus your testing with a smaller amount of data. Use the data files that I have provided for your final testing once you have everything working.
In a file named HONOR, include the following statement with the appropriate modifications:
In accordance with the class policies and Georgetown's Honor Code, I certify that, with the exceptions of the class resources and those items noted below, I have neither given nor received any assistance on this project. Name NetID
Instructions for Electronic Submission
Submit p1 exactly like you submitted hw1. Make sure you remove all debugging output before submitting.
Assuming all of your code is in the subdirectory p1, then with the Makefile I provided you can type:
cs-class% ls p1/ cs-class% cd p1 cs-class% make submit rm -f submit.zip zip submit.zip main.cpp calendar.cpp event.cpp datetime.cpp main.h calendar.h event.h datetime.h Makefile HONOR adding: main.cpp (deflated 59%) adding: calendar.cpp (deflated 69%) adding: event.cpp (deflated 73%) adding: datetime.cpp (deflated 76%) adding: main.h (deflated 29%) adding: calendar.h (deflated 52%) adding: event.h (deflated 62%) adding: datetime.h (deflated 60%) adding: Makefile (deflated 61%) adding: HONOR (deflated 32%) cs-class% ls a.out* calendar.o datetime.h event.h LICENSE main.cpp Makefile calendar.cpp icloud.in datetime.o event.o main.h submit.zip calendar.h datetime.cpp event.cpp iphone.in main.o
Notice the presence of the file submit.zip in the directory. Use a secure file-transfer program (sftp or FileZilla) to transfer the zip file from cs-class to your laptop.
You can also produce this zip file on your laptop, but it is imperative that the zip file contains only the files of your project with no subdirectories.
To submit the zip file for a compile check or provisional grading, use your browser to log on to Georgetown's instance of Autolab. Navigate to the correct course and assignment, and submit your file.
You can submit to Autolab seven times. You can perform five compile checks, and you can perform two project submissions that are automatically graded. The last automatically graded submission is the grade for the project.
Once you've submitted your project, it is important to keep an electronic copy on cs-class that preserves the modification date and time. If we lose your project or the submission system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.
(Additional useful Linux and Unix commands)
Copyright © 2023 Mark Maloof. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.