Project 1
Due Monday June 11th at the start of lecture
Introduction
The project that we are going to work on durring class this session is a personal information manager (PIM). Think of this is as a much less mobile version of the palm pilot.
The PIM will have 3 kinds of things that can be stored in it: memo, event, address.
- Memo The PIM is organized arround the an object called a memo this holds 4 pieces of data:
- creation time: (month,day,year,hour,min).
- unique id
- title
- text of memo.
Note: Only the title and the text of the memo can be update after creation.
- Event A memo extended with an event time field that stores when the event will occur. This takes the same form as the creation time, think carefully about how you are going to store this data because you must be able to update it. All of these may be changed after creation.
- Address A memo extended with:
- Name
- Email
- Phone
Again all of these fields may be changed after creation.
What you will need to do
You will need to the base class of a memo and the 2 sub classes of event and address along with a driver program that will allow these to be tested.
methods each class must have are listed below. If you wish to add others you may.
class Memo
- a constructor that takes 5 integers representing:month, day, year, hour, min as these are the creation time, this should also set the unique id field to a unique id and set the title of the memo to the string "Untitled"
- a method, void update_title(String s) that will replace the current title with the contents of s.
- a method, String get_title( void ) that returns the contents of the title.
- a method, void update_text(String s) that will replace the current contents of text with s.
- a method, String get_text( void ) that returns the contents of the current text field
- a method, void print_memo( void ) that will print the title and the contents of the text field.
- a method, void diagnostic( void ) that will print the contents of all the data members with identification including private data members.
class Event
- A constructor that takes 5 integers representing:month, day, year, hour, min calls the superclass constructor to set these and sets all of the local variables to empty.
- A method void set_time( int hour, int min ) that sets the time of an event
- A method int get_hour( void ) that returns the event hour
- A method int get_min( void ) that returns the event min
- A method void set_date( int month, int day, int year) that sets the date of an event.
- A method int get_month( void ) that returns the event month
- A method int get_day( void ) that returns the event day
- A method int get_year( void ) that returns the event year
- a method, void update_title(String s) that will replace the current title with the contents of s.
- a method, void update_text(String s) that will replace the current contents of text with s.
- a method, void print_event( void ) that prints out the Title, date, time and text field from the event.
- A method, void diagnostic( void ) that will print the contents of all the data members with identification and calls the super class diagnostic to get all of that data.
Address
- a constructor that takes 5 integers representing:month, day, year, hour, min as these are the creation time, this should also set the unique id field to a unique id and set the title of the memo to the string "Untitled"
- a method, void update_title(String s) that will replace the current title with the contents of s.
- a method, void update_text(String s) that will replace the current contents of text with s.
- a method, void update_name(String s) that will replace the current contents of the name with the contents of s.
- A method String get_name( void ) that returns the name field
- a method, void update_email(String s) that will replace the current contents of the email with the contents of s.
- A method String get_email( void ) that returns the event email
- a method, void update_phone(String s) that will replace the current contents of the name with the contents of s.
- A method String get_phone( void ) that returns the event phone number
- a method, void print_address( void ) that will print the title and the contents of the various address fields.
- a method, void diagnostic( void ) that will print the contents of all the data members with identification.
The driver program should make it possible to test each of the classes that you created so it will have to allow for information to be entered and viewed. The driver program does not need a GUI interface. However it will need a main method that creates 1 or more objects of each class and prove that data may be entered into each object. Your driver program should also demonstrate the ablity to update the approperate members of each class. There are two basic methods for constructing this sort of driver program, interactive or batch.
The interactive case is often handled with a menu an example run might look something like this (bold text represents the typing of the user.
start of run-------->
Test (M)emo, (E)vent, (A)dress: M
Enter the date and time of creation: 01 02 2003 5 42
diagnostic print
unique id: 1
creation day:01, month:02, year:2003, hour:5, min:42
title: Untitled
Text:
Update (T)ext or t(I)tle: T
Enter the new text: This is the new text
calling print memo to demonstrate update
memo: Untitled
text: This is a the new text
Lots more testing each piece of classes
----------->end of run
The main advantage is that you can control each run to test just the protions of the code that you wish to.
A batch tester run might look something like (notice the user types nothing):
start of run-------->
Testing memo class
creating memo with creation date of 01/02/2003 time 5:42 no title and no text
diagnostic print
unique id: 1
creation day:01, month:02, year:2003, hour:5, min:42
title: Untitled
Text:
updating text with "this is a test"
using get_text() to see if change worked
worked input text: this is a test, result of get_text: this is a test
------->end of run
The advantage of a batch tester is consitency, it will do exactly the same thing each time and you don't have to worry about testing typos at 3am.
Limitations of the code
- you do not need to try collect the creation time from the system but can prompt for this information.
- The system should generate the unique id for each memo, this may be sequential or any other way you chose but be carefull to document the method in your code and why it will generate a unique id.
- You do not need to worry about detecting events experations etc but you do need to be able to print out this information.
Thought question 10% of project grade
How would you handle an event that recures on a regular basis, for example a class that meets only on Thursdays at 3:30 and only for a few months. Given that space is a concern in a PIM how would you do this with out creating an event for each time the class meets?
What to hand in
- A print out of your code
- your answer to the thought question
What to submit
Just the code.