CPS209 Assignment 2:Extended Daily Appointment Calendar solution

$35.00

Original Work ?

Download Details:

  • Name: Daily-Appointment-Calendar-2-fbskcr.zip
  • Type: zip
  • Size: 106.04 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (2 votes)

You are to extend the Daily Appointment Calendar program from assignment 1. This programming assignment will increase your knowledge of objects and classes, inheritance, interfaces, GUIs, File I/O and Exceptions, Linked Lists and Stacks. You must do this assignment alone – no groups. Do not attempt to find source code on the web for this assignment. It will not help you and you risk extremely serious consequences. Your program will be checked for plagiarism. Begin designing and programming early! This assignment is worth 10 percent of your mark. If there is some part of the assignment you do not understand, please see me (or email me) or ask me in the lecture as soon as possible and I will clarify the issue.

 

Program Functionality Requirements:

I will be posting a sample solution to assignment 1 a few days after the due date for those students who wish to work with my solution for assignment 2. Once I have done so, no further assignment 1 submissions will be accepted. Your program should extend assignment 1 with the following functionality. NOTE: see the marking scheme at the end of this document. The month view code (see figure above) is a bit tricky so I am not weighting it much. You can still get a good mark if you decide to skip this part.

NOTE: you are welcome to add other methods to the classes below or change the names of the suggested methods. However, please create the classes below and have them contain the variables as stated.

1.  Create a class Person. Class Person should contain instance variables lastName, firsName, telephone, address, email – all of type String. Here are some suggested methods for class Person. Add constructor, get/set methods. Add a toString(). In addition, you must have the following:

a.  Class Person should implement the Comparable interface. You should be able to compare two person objects based on their lastName and firstName. That is if the last names match, use their first names to compare, otherwise use last name.

b.  Construct a class that implements the Comparator interface. This class compares two Person objects based on their email address.

c.  Construct a class that implements the Comparator interface. This class compares two Person objects based solely on their telephone number.

// Need to do number 2 underneath it

2.  Alter class Appointment by adding another instance variable that stores a reference to a Person object. Alter constructor methods, add get/set methods.

3.  Create a class Contacts. This class must contain a LinkedList of Person objects. Note: we are using LinkedList solely for you to gain experience working with it. An ArrayList would probably be better. Here are some methods that class Contacts should support:

a.  Several FindPerson() methods that take in parameters such as email address or last name, first name or telephone as arguments.  These methods search the LinkedList and if they find the matching Person, they return a reference to the Person object, otherwise they return null. They should use the appropriate comnpareTo or compare methods of Person.

b.  A method readContactsFile(). This method opens a txt file (create a contacts.txt file and manually add information to it. The format of this file will be explained below). It reads the contacts file and builds Person objects, and inserts them onto the LinkedList. It sorts the LinkedList. The format of the contacts file is:

·   The first line of the file contains the number of “records” in the file (i.e. the number of persons)

·   The 2nd line contains the last name, 3rd line contains: first name, 4th line: address, 5th line: telephone, 6th line: email.

·   Then the 2nd through 6th lines are repeated for the next person.

c.  readContactsFile() should be called once only at the beginning of the program. Where it is called should be surrounded by “try{…}catch(){…}. If an exception occurs, print a message to the user in the Description textArea or in a separate Message area (create one).

d.  If the first line of the contacts.txt file does not contain a valid integer, throw an exception. If the last name of a person or email of a person is blank, throw an exception. If the number of lines of the file (excluding the first line containing the record count) is not a multiple of 5 then throw an exception. In general, if something goes wrong with reading the contacts.txt then you should make sure the LinkedList is empty before throwing an exception. This will mean your Appointments program will still run but you will not be able to search the LinkedList looking for a person with the given name or email.

4.  Create a GUI Panel called Contact (see figure above) for entering person information. If you enter the email and press Find then the rest of the information for that person (if it is found in the Contacts LinkedList) should be filled in. Similarly, if you enter just the telephone, or both the last name and first name.  The Clear button clears the person information.

5.  I have renamed the Action panel the Appointment panel. When creating a new appointment, check to see if there is Person information entered. If so, add the Person object to the appointment object. When printing the appointment, print the person’s name, tel, and email in addition to the other appointment info. If either or both telephone or email is blank, print nothing for these fields.

6.  Create a Stack of Appointment objects and add it to the AppointmentFrame class.  This stack keeps track of appointments in the order they were created. This allows us to undo appointments. For example, if we created 3 appointments on different days in different months, but want to delete them, we need to be able to recall them. When an appointment is created, add the appointment object to the Stack. Add a RECALL button to the Appointment panel (see figure). When this button is pressed, the last appointment made is printed. That is, the calendar changes to the day of the last appointment, and all of the appointments on that day are displayed. The hour and minute textfields in the Appointment panel are filled in with the hour and minute of the last appointment. The user now has the option of cancelling this appointment. Hint: use the “peek()” method of class Stack when recalling the last appointment. Use the “pop()” method only if the user cancels the appointment. Finally, if the user cancels some other appointment on a random day, you must go through the Stack to see if it is stored there. If it is, you must remove it from the stack.

7.  Add error checking on all fields where you enter information and the information has some valid range. For example, the day of month field can only be between 1 and 31 for some months, 1 and 30 for others, and 1 and 28/29 for February. If the user enters invalid information, display a message in the Description panel (or add a separate error message panel if you prefer, with a Clear button.

8.  Create a Month View Panel (see figure above) that has buttons for each day of the current month. When a button is pressed, the date is changed and the appointments on that day are printed. If the user presses the ‘>’ button in the Date panel, and the month changes, then the Month View Panel should be updated. Highlight the currently pressed Day button in the Month view panel so its background is red. The code for this part is a bit tricky. I will assign only 1 mark for it and I suggest you leave it to the end if you have time.

9.  As a bonus, add the ability to show which days have appointments in the month view panel. Add the ability to scroll through month by month (next and prev month).

10.Control Panel: alter the control panel to appear as above in the figure. If you are not implementing the Month View Panel, you should create another button in the Date panel that sets the calendar to the current date.

11.Make sure you comment your code. I strongly urge you to use JavaDoc.

Grading (Out of 10 marks)

 

Class Person and class Contacts as described above. Maximum 5 marks
Everything above plus ability to add person info to an appointment Maximum 6 marks
Everything above plus error checking on all fields where it makes sense. Maximum 7 marks
Everything above plus the recall stack functionality Maximum 9 marks
Everything above plus the month view panel as described Maximum 10 marks
Month view panel can show which days have appointments, next and prev month buttons Maximum 10.5 marks

Submitting Your Assignment

  • Use D2L to submit your assignment.
  • Inside each of your “.java” files have your name and student id as comments at the top of the file. Make sure your files can be compiled as is without any further modification!!
  • Include a README.txt file that describes what aspects of your program works and what doesn’t work (or partially works). If your program does not compile, state this.
  • Place all your “.java” file(s) and README.txt file into an archive (zip or rar archiving format only).
  • Open your archive and make sure your all your files are there.
  • Do not include “.class” files!!!!
  • Once everything is ready, submit it.