COSC-052: Computer Science II

Project 1
Spring 2020

Due: W 2/5 @ 5 PM
6 points

In this project, you will use classes and object composition to implement software that synchronizes events of a calendar between two devices, such as between a computer and an iPhone. I have produced a design document for the classes and methods you need to implement for this project.

To demonstrate your classes, the main function should take two input files from the command line, synchronize the calendar events in those files, and write the synchronized set of events to two output files. The main function should also catch invalid_argument and logic_error exceptions 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 computer iphone
should read the events in the files computer.in and iphone.in, synchronize the events, and write the synchronized events to computer.out and iphone.out.

The data format for these files consists of seven tab-separated fields: a character indicating the status of the record (i.e., whether it is active or deleted), a string that is the unique identifier of the event, a string delimited with double quotes that is the name of the event, a string delimited with double quotes that is the location of the event, a date and time indicating the start of the event, a date and time indicating the end of the event, and a date and time indicating the event's last date of modification. Two examples of events in this format are as follows:

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

The first thing you should do is implement the DateTime class, which you will use to store the start, end, and modification dates and times for events. The set methods must do 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 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 multiple devices. We'll talk about this in lecture.

Getting Started

Although you may use any development environment for your project, it must compile and execute on cs-class. Make sure it compiles and runs without error on cs-class before submitting to Autolab.

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  computer.in   datetime.h  event.h    LICENSE   main.h
calendar.h    datetime.cpp  event.cpp   iphone.in  main.cpp  Makefile
cs-class% cd ..
cs-class% ls
p1.zip p1/
cs-class% rm p1.zip
These 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, you have a Makefile and .cpp and .h files for the project. The files computer.in and iphone.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 would recommend creating your own data files in a simplified, minimal format. I would 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, I would 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:

Name
NetID

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.

Instructions for Electronic Submission

You will 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 61%)
  adding: calendar.cpp (deflated 70%)
  adding: event.cpp (deflated 73%)
  adding: datetime.cpp (deflated 76%)
  adding: main.h (deflated 29%)
  adding: calendar.h (deflated 52%)
  adding: event.h (deflated 63%)
  adding: datetime.h (deflated 62%)
  adding: Makefile (deflated 62%)
  adding: HONOR (deflated 32%)
cs-class% ls
a.out*       calendar.o    datetime.h    event.h     LICENSE    main.cpp
Makefile     calendar.cpp  computer.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, 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 Unix commands)

Plan B

If Autolab is down, upload your zip file to Canvas.

Copyright © 2020 Mark Maloof. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.