CS367 Programming Assignment 1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Announcements
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
OverviewWhy are we doing this program? DescriptionEpoch Systems of Anorev, Wi is a leading software firm. It often requires that employees visit customers to discuss implementation and integration issues. Such meetings are often called "Go Jive" sessions. To improve employee morale, Epoch has decided to allow employees to declare a "wish list" of destinations. Travel assignments will be matched against employee preferences (to the extent possible). Epoch is not quite ready to go live — it needs a way to manage employees and their wish lists. It has hired you to start working on a simple prototype. For this assignment you will write a program that constructs a simple database of employees and wish lists containing destinations encoded as airport identification codes (e.g., MSN or ORD). (Click here for a utility that maps airport names and their three letter codes). Your program will process a text file, specified as a command-line argument, using it to construct an employee database. It will then repeatedly prompt the user to choose from a set of operations and display the resulting output on the console window. For Programming Assignment 1 you will not be building an abstract data type (ADT) from scratch. Instead, you will use Java's ArrayList class to implement the EmployeeDatabase class specified below. GoalsThe goals of this assignment are to:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
SpecificationsWhat are the program requirements? Input text filesText files storing employees and destinations will be read by your program. Each line in the text file lists an employee (as a username) followed by the destinations (as airport id codes) in that employee's wish list in the following format: employee,destination1,destination2,...,destinationN where the employee and destinations 1 through N are sequences of characters excluding commas and spaces (i.e., "," and " "). You may assume that the text files are in the specified format and contain at least one employee. You may also assume that each employee has at least one destination in their wish list and that there are no duplicate destinations within a single employee's wish list (see this sample input file for an example). You may also assume that employee usernames and airport id codes are unique* and are to be represented by your program as lower-case Strings. *Note: for both employees and airport id codes, differences in capitalization should be ignored, e.g., UGM2016, ugm2016, and Ugm2016 should all be considered the same and represented in the database as ugm2016. Note: employees are to be added to the employee database in the order in which they appear in the text file. Information about Java I/O is available in both a long version and a short version. Examples of file input are linked to in those documents. The Employee classAn Employee class is provided for you (see Employee.java). The Employee class represents a single employee that keeps track of a username (as a String) and the airport id codes in the employee's wish list (as a List of Strings). The Employee class has the following constructor and methods:
You may not modify the Employee class. If you need to make a change to the wish list a particular employee has, use getWishList() to get the list of airport id codes in the employee's wish list and then use list operations to add, remove, etc. The EmployeeDatabase classThe EmployeeDatabase class stores the employees. The EmployeeDatabase class has the following constructor and methods (do not add any additional public methods other than those listed below):
For the internal structure of the EmployeeDatabase class, you may write your own ArrayList class or use Java's ArrayList class that implements Java's List interface. You must also make use of Java Iterators where appropriate (i.e., whenever you need to traverse a list). You may also write additional helper classes to be used by the EmployeeDatabase class. Note: in addition to the information given in the table above, your EmployeeDatabase class will need to be able to recognize null parameter values and, when a null parameter value is passed, throw a java.lang.IllegalArgumentException. The InteractiveDBTester classThe application program, InteractiveDBTester, creates and uses a EmployeeDatabase to represent and process information about employees and wish lists. The employee and wish list information is read from a text file (explained above) and then the program processes user commands. The application must make use of Java Iterators where appropriate (i.e., whenever a list is traversed). The InteractiveDBTester.java file contains the outline of the InteractiveDBTester class. Download this file and use it as the starting point for your InteractiveDBTester implementation. Note that it contains all the necessary code to read user input from the console. You do not need to modify that part of the code. When we test your code we will only input legal commands in the appropriate format. The main method of the InteractiveDBTester class does the following:
The command options are:
Command-line argumentsRecall that in Java, when you run a program, it is a main method that runs and that main method always has the following header: public static void main(String[] args) The array-of-Strings parameter, args, contains the command-line arguments that are specified when the program is run. If the program is run from a command prompt (i.e., not from a programming environment like Eclipse), the command-line arguments are simply typed after the name of the class whose main method is to be executed. For example: java InteractiveDBTester employeeData.txt runs the Java interpreter on the main method of the InteractiveDBTester class, passing the string "employeeData.txt" as the command-line argument. To use command-line arguments when you run a Java program using Eclipse:
How to proceedAfter you have read this program page and given thought to the problem we suggest the following steps:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Handing inWhat should be handed in? Make sure your code follows the style and commenting standards used in CS 302 and CS 367. Electronically submit the following files to the Program 1 Dropbox on Learn@UW:
Please turn in only the files named above. Extra files clutter up the "handin" directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Updated: 8/10/2016 © 2016 Beck Hasti and Charles Fischer |