COSC 072: Computer Science II

Project 1
Spring 2010

Due: Wed, Feb 10 @ 10 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 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. Input files will have the extension .in, whereas output files will have the extension .out. For example, the command

seva% 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 fail silently, meaning that if a parameter is incorrect or is out of bounds, then the set method does not replace the existing value. 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 created on one device should be copied to the other device. Events modified on one device should be updated on 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 seva. 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

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

For convenience, I have placed two input files on seva, 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:

seva% cp ~maloofm/cosc072/*.in ./
seva% 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 cosc072 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. The complete Makefile for p1 is Makefile.p1. You can copy them from my directory into your current directory on seva using the commands:

seva% cp ~maloofm/cosc072/Makefile ./
seva% cp ~maloofm/cosc072/Makefile.p1 ./
If you're coding on a Windows machine, you may need to edit the Makefile and change the .cc extension 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:

seva% 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 072 Project 1
 * Name: <your name>
 * ID: <GoCard ID>
 * E-mail: <e-mail address>
 * Instructor: Maloof
 * TA: <TA's name>
 *
 * 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 to your TA about 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:

seva% ls
p1/ submit.jar

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

seva% cd p1
seva% make clean

If you need to include a message to your TA or me about your submission, then place the message in a file named README. Place the README file in the project's directory.

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

seva% cd ..
At this point, you should be above the p1 directory:
seva% 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

seva% mv p1 maloofm
Create a zip file of the directory and its contents by typing
seva% 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

seva% 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., seva) 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,

seva% 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:
seva% rm p1.zip

The TA who will be grading your projects this semester is listed on the main page. You must submit your project before 10 PM on the due date.

Plan B

If you're running submit correctly and you see an error message labeled as SEVERE, then it's time to execute Plan B by using mail to submit your project. Do this only if Plan A fails. Follow the directions detailed in HW1.

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