Question
Write a program in Java that:Short Description: Creating an object oriented (also referred to as OO) program that helps a user build and manage a
Write a program in Java that:Short Description: Creating an object oriented (also referred to as OO) program that helps a user build and manage a to do list. At a very minimum you will need to create three classes o a starting point the main and anything used for the basic flow of the program o ToDoEntry holds information and functionality about a single to do list entry Priority and description o ToDoList all functionality related around managing a list of to do entries. This class should not include any communication with the user other than reporting errors. You cannot use the key word static anywhere in your program except for the main. Long Description: In an object oriented design, important data structures are encapsulated in classes. The client code instantiates objects and then communicates with these objects via their public interfaces (methods). It has no access to their private implementations. At run time, an object oriented system is often viewed as an intercommunicating network of objects and client code. When the program is run it reads a text file; to_do.txt. If the file is empty or the file name does not exist, the program starts with an empty to do list. Otherwise, it attempts to open the file and, if successful, creates a to do list of the items in the file. Example, to_do.txt might look like: 1 finish COMP 2503 assignment 1 2 pay overdue MasterCard bill 2 do laundry 3 drink 2 buy groceries 1 make dentist appointment The integer at the beginning of a line is the items priority (3 = high, 2 = medium and 1= low). If the integer value is not 1, 2 or 3, then it defaults to a value of 1 (low). Page 2 of 5 If any errors occur when reading information on a line (i.e., missing the priority integer or missing description) output an error message to the console and the entire line that was wrong and continue to the next line in the file. When the program quits, it writes information to out.txt. If this file exists, then it is overwritten. Otherwise, a new file is created and all information is written out. The output format must match the input format (to_do.txt) for the program as shown above. The current list will be written out using the following format: 3 drink 2 pay overdue MasterCard bill 2 do laundry 2 buy groceries 1 finish COMP 2503 assignment 1 1 make dentist appointment Once the initial to do list has been read, the program will read the commands from cmd.txt repeatedly until no more commands are left in the file. You can assume that there will be no errors in the cmd.txt file. The cmd.txt can contain four different commands: d (display), a (add), r (remove), and u (update). An example cmd.txt might look like: d a h phone Aunt to wish her happy birthday r 2 u 4 h d Each of the four commands are explained below using the example from to_do.txt discussed above. The d command, i.e. display will display the current list to the screen using the following format: High Priority: 1: - drink Medium Priority: 2: - pay overdue MasterCard bill 3: - do laundry 4: - buy groceries Low Priority: 5: - finish COMP 2503 assignment 1 6: - make dentist appointment Note that the list items are numbered. These numbers will play a part in the remove and update commands. Page 3 of 5 The a command (i.e., add) will be in the following format in the cmd.txt file: a h phone Aunt to wish her happy birthday In the above example, a is the command for add, followed by a single character for the priority (h / m / l) and then followed by the description. The new list item must be added at the end of the sub-list of the given priority. For example, if the display command was re-executed after the above a command is completed, it would display the following: High Priority: 1: - drink 2: - phone Aunt to wish her happy birthday Medium Priority: 3: - pay overdue MasterCard bill 4: - do laundry 5: - buy groceries Low Priority: 6: - finish COMP 2503 assignment 1 7: - make dentist appointment Notice we have a second entry under high priority and the list numbers have been updated to accommodate this. The r, remove command behaves as follows: r 4 d Here, r is remove, and 4 is the item number in the display list. In our most recent example, do laundry is the item to be removed. Now, d will display the list after removing item 4: High Priority: 1: - drink 2: - phone Aunt to wish her happy birthday Medium Priority: 3: - pay overdue MasterCard bill 4: - buy groceries Low Priority: 5: - finish COMP 2503 assignment 1 6: - make dentist appointment Notice the previous list item #4 do laundry is removed and the list numbers have once again been updated accordingly. Page 4 of 5 The u or the update command allows users to change the priority of a given item. For example, if the user suddenly realizes that the assignment is due soon, then the command read will be: u 5 h d Here, u stands for update, 5 is the item number and h is the new priority. After the update, the list will be displayed as follows: High Priority: 1: - drink 2: - phone Aunt to wish her happy birthday 3: - finish COMP 2503 assignment 1 Medium Priority: 4: - pay overdue MasterCard bill 5: - buy groceries Low Priority: 6: - make dentist appointment Notice that the entry finish COMP 2503 assignment 1 is now listed at the end of the high priority section. Once the command file has been read, the program will write the to do list to a text file called out.txt. Below is a sample of the output file for our example after the cmd.txt is executed: 3 drink 3 phone Aunt to wish her happy birthday 3 finish COMP 2503 assignment 1 2 pay overdue MasterCard bill 2 buy groceries 1 make dentist appointment
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started