Course web page: Introduction to Computer Science for non-majors II James Tam | Return to the course web page |
CPSC 219: Full Assignment 2 |
Due Friday Feb 17 at 4 PM
Write a Java program that allows a person to track a list of vacation sites. The full version of the program will allow the user to perform some common list management functions, such as add, displaying, modifying or removing sites.
The program consists of 4 classes: Destination (place to travel to), Manager (implements the list management features), UserInterface (responsible for text based user input/output), Vacation (the 'driver' of the program).
Description of the fields
1. Name
The name of the site will be stored as a string of characters.
2. Vacation type
This field describes the main reason for traveling to this location. There can be four different categories of sites with each one being represented by a single character code: relaxation (r), excitement (e), culture (c) or food (f). For the add and modify features your program must be able to check that the user only enters one of these characters for the vacation type and if not it will repeatedly prompt him or her to enter a valid value. For this assignment you can assume a particular site will not be categorized in multiple ways. Note: When the user is prompted to enter in the information for a new site he or she will be prompted to only enter in a single character. However when the information for a site is displayed it show a full description for the vacation type. (For example, instead of displaying 'r' the program should display something more descriptive like 'relaxation'). Ideally the prompting methods should be part of the UserInterface class. Due to the increased complexity of this approach however you can implement the required methods as part of this class.
3. Rating
This field is a numerical value from 1 - 5 that indicates how much that the person wants to go to a particular vacation spot with 5 being the most desirable and 1 being the least desirable. As was the case with the previous attribute, your program must be able to check that the user enters a value within this range and will repeatedly re-prompt him or her to enter in a proper value when this doesn't occur until a valid value has been entered.
Manager class: Manager: Stores the array of vacation destination sites, implements the list management functions (display, add, modify, remove, search). Your program should be able to track a reasonably large number of vacation sites (e.g., 100).
A basic version of the program will only add and remove elements from the end. A superior version (higher grade) can perform an in-order add (alphabetically ordered by destination name case insensitive e.g. 'cambodia' always comes before 'Canada') although the program doesn't have to check for duplicates (e.g. 'London' Ontario vs. 'London' England and the program could allow for two entries of 'London's).
As well the superior program can allow the user to specify the destination name and remove the first instance where the destination name entered by the user matches the destination name of an element in the list.
With the 'modify' feature, the program searches and modifies the first instance of a particular destination name while search displays all instances of given name.
Finally with the 'display' feature only occupied array elements will be displayed. For instance if the array can contain 100 destinations but the user has only entered 3destinations then only three array elements will be shown onscreen. To help you visualize how the superior list management features will work here is a set of notes describing how a list management features such as add and remove be implemented. [Extra notes on lists]/ The source code can be found through this [web link] or in UNIX under: /home/219/assignments/assignment2/code
UserInterface class (UI): similar to the class with the same name covered by the TAs in tutorial which can be found at [this link] or in UNIX under /home/219/tutorials/jan29_feb4/userInterface. For this program the UI class will implement the code for displaying, getting input for this menu, validating the input and then sending an appropriate message to the Manager class. Consequently the UI needs a Manager as an attribute. (E.g. when the user selects option 'a' from the menu then the UI will notify the Manager class that it should run it's 'add' method or methods).Valid menu options for the main menu include:
The program should detect an invalid selection and display an appropriate error message. However input should be case sensitive e.g. 'a' or 'A' invokes the first option.
Vacation class:
The starting execution point for your
program. You should probably instantiate an instance of class
ManagerUserInterface in the 'main()'
method.
As well as being marked on whether "your program works" you will also be marked on non-functional requirements such as style and documentation. Consequently this assignment will include a separate [marking checklist]
Points to keep in mind:
D2L configuration:
Marking: