COSC 052: Computer Science II

Project 1
Spring 2013

Due: Fri, Feb 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 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 catch invalid_argument 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.

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 before submitting.

Place all of your code in a subdirectory named p1. To create this subdirectory, type

cs-class% mkdir p1
To descend into the directory, type
cs-class% cd p1
All of the files for your project should be in this directory.

For convenience, I have placed two input files on cs-class, computer.in and iphone.in. These files contain real events from my calendar, mainly so you can see what an exciting life I lead. To retrieve these files, type:

cs-class% cp ~maloofm/cosc052/*.in ./
cs-class% ls
computer.in   iphone.in
These commands create a new directory named p1, descends into that directory, copies all of the files with a .in extension from my cosc052 directory to your current directory (./), and lists those files showing that they have been copied correctly.

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.

You must provide a working Unix Makefile with your submission. Start with this Makefile, which compiles a project consisting of main and DateTime. You can copy it from my directory into your p1 directory on cs-class using the commands:

cs-class% cp ~maloofm/cosc052/Makefile ./
If you're coding on a different platform, you may need to edit the Makefile and change the .cc extensions to .cpp.

If you want to copy files from the hw1 directory to the p1 directory, assuming you're in the p1 directory, to copy main.cc, type:

cs-class% cp ../hw1/main.cc ./
You can do the same for other files and edit them, rather than typing them from scratch.

At the top of the file main.cc (or the file containing the main function), place the following header comment, with the appropriate substitutions:

/*
 * COSC 052 Project 1
 * Name: <your name>
 * ID: <GoCard ID>
 * E-mail: <e-mail address>
 * Instructor: Maloof
 *
 * 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'll be submitting p1 exactly like you submitted hw1. If you need to include a message with your submission, then place the message in a file named README. Place the README file in the project's directory.

Assuming all of your code is in the subdirectory p1, directory, this directory and the submit program should be in the same directory:

cs-class% ls
p1/ submit.jar

To reduce the size of the zip file, before submitting, remove all object and executable files:

cs-class% cd p1
cs-class% make clean

To move from the p1 directory to the parent directory, type

cs-class% cd ..
At this point, you should be above the p1 directory:
cs-class% ls
p1/ submit.jar

(Additional useful Unix commands)

When you are ready to submit, change the name of the directory to your netid. For example, if your netid is maloofm, then rename the directory p1 by typing

cs-class% mv p1 maloofm
Create a zip file of the directory and its contents by typing
cs-class% zip -r p1.zip maloofm/*
This command creates a zip file named p1.zip by recursively (-r) copying all of the files (*) from the directory maloofm/.

To submit the zip file type

cs-class% java -jar submit.jar -a p1 -f p1.zip
p1 is the name of the assignment (-a) and p1.zip is the file (-f) to be submitted for that assignment.

If the program submits the file successfully, you will receive a receipt by e-mail at the address <netid>@georgetown.edu.

Submit your project only once.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., 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.

You can also change the directory's name back to the original name. For example,

cs-class% mv maloofm p1
Note that changing the name of the directory does not change the dates of the files in the directory. You can also remove the zip file from your directory:
cs-class% rm p1.zip

Submit your project before 5 PM on the due date.

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