代写Homework 1: Citation Support System v.0代写Java编程
- 首页 >> OS编程
Homework 1: Citation Support System v.0
Due: Monday, October 3rd, 11:59 pm
You will write a first version of the Citation Support System, a program that manages citations (also known as tickets or violations) for a police department. It will model information about each citation – for example, the type of citation, the person who issued it, and notes - demographic data about the person being cited, and the routing information for the citations. This is just a simulation, leaving out many details of how this would work in practice – for example, managing privacy using access rights and encryption (among other things).
Design:
The core class is Citation, which keeps track of basic information about a ticket. Each Citation has a related Person, which contains the demographic information about the person to whom the ticket was issued. CitationList keeps track of 0 or more Citation objects. The driver of the app is hw1Main.
The classes below should have a default constructor and an overloaded constructor (that sets all the fields in the order given); a full set of getters and setters; a toString( ) method used for display; and a toCSV( ) method, which returns a CSV String used for writing to a file.
Class Citation: Models one ticket
Data:
String typeOfOffense: for now, only "Parking", "Speeding", "Jaywalking", and "Inebriated" are the only offenses. String description: free-form details of the offense
int number: unique key, set to the citationCounter if this is a newly-created citation.
String date: the date of the citation
Person person: the perpetrator of the crime
Class Person: Models the person receiving a Citation
Data:
String firstName, lastName, address, phoneNumber
Class CitationList: This class encapsulates the list of Citations. Note: its overloaded constructor only sets authority and title; listOfCitations should be new'd up to an empty list. Similarly, only getters and setters for authority and title are required.
Data:
ArrayList<Citation> listOfCitations: all the Citations in the system
String title, authority: the official in charge of all Citations. Set these to "Chief" and "Barrett".
Methods:
readCitationFile(String filename) – reads a Citation CSV file.
writeCitationFile(String filename) – writes a Citation CSV file.
toString( ) – use a StringBuilder to construct this String, since there could be a large number of Citation objects. displayCitationType(String typeOfOffense) – display any Citations with that typeOfOffense
dispayCitation(int number) – display the Citation with that id number
displayCitation(String lastName) – display any Citations whose Person object has that last name newCitation( ) – prompt the user for the information for one new Citation, add it to
listOfCitations
Class Menu: Models the user menu choices
String[] menuChoice: the menu choices (described below).
static int displayMenu( ): displays the menu, prompts for the user's choice and return it. Return 0 if there's an error.
Class hw1Main: The main program.
public static Scanner – for the keyboard; used in both main( ) and in CitationList.
CitationList citationList – the list of Citation objects.
When the program starts, the main function creates a CitationList object called citationList and reads a CSV file of Citation-Person data (see below for the file format). The user interface has these menu options:
0. Quit.
1. Display all the Citation data using CitationList.toString()
2. Display all Citations by chosen typeOfOffense.
3. Search for a Citation by number.
4. Search for a Citation by Person last name.
5. Add a new Citation.
Options 1 and 2 only display the base Citation data, not the related Person. Options 3 and 4 display all information about the given Citation, if found, including the associated Person. Option 5 also creates a Person for the new Citation. See below for sample output. At the end of the program, write the CSV file (even if it is unchanged). The CSV file has the format:
number,typeOfOffense,description,date,first name, last name,address,phone number as in:
1,Speeding,50mph,23-Aug-2023,Mary,Smith,123 Main
Street,412-555-5555 Here's a sample of Option 1 for a small test file; make your
toString( ) methods produce this. Citation List
Chief Barrett
Citation #1
Type Of Offense: Speeding
Description: 50mph
Date: 23-Aug-2023
Person: Mary Smith 123 Main Street 412-555-5555
Citation #2
Type Of Offense: Jaywalking
Description: Forbes Avenue
Date: 10-Sept-2020
Person: John Doe 456 Elm Street 412-001-0010
Deliverables: Zip up *only* your .java files; name it <your Andrew id>_hw1.zip. Upload it to Canvas. Hints: Don't try to code the whole assignment at once. The ordering of the methods above may not be the order you want to code them in, either. If something is unclear, or ifyou’re just wondering about how to do something, ask!
Grading Rubric:
1. 80% on console output and test cases (these will be posted later).
2. 5% documentation: document each class and each method. Document your code only where needed – where the person grading it might have trouble understanding.
3. 5% Code quality: variable names, optimal loops, etc.
4. 5% Robustness: your code should not crash while processing reasonable data.
5. 5% Following submission instructions. NO LATE SUBMISSION, PLEASE!