Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please can you help me with this program You are required to write an interactive program that reads commands from the user, executes the c

please can you help me with this program

image text in transcribedimage text in transcribed

You are required to write an interactive program that reads commands from the user, executes the c omm ands and displays results (if nec essary) to the user. The program must continue to read and process commands from the user until the exit command is given if an unrecognized command is given, then the program should print the error message: Unrecognized Command, and continue to read input Your program is required to maintain a linked list where each node contains the following data 1. Task: A string representing a task to be completed. Throughout this application, you may assume that each task is described by a string containing no white space characters 2. Date: A date for which the task must be completed by. Details regarding the format for dates can be found below 3. Complete: A Boolean_eld that indicates if the task has been completed or not 4. Completed Date: A_eld that indicates the date that the task was completed. If the task is actve then this eld should remain null. Thus, your program implements a lto-do lit application. The program tracks tasks to be completed, the date when the task must be completed by, and if the task has yet been completed. The commands (described below) are used to add tasks to the list, mark a task as completed, update the deadline of a task, and so on Additionall,y your program will also support saving the list of tasks to a_le so that the list can be recreated for successive runs of the program. The linked list must also satisfy the following important property Property 1: All of the tasks contained in the list are unique Furthermore, for all applicable input, your program should be case insensitive. For example, the c omm and ins should be recognized also as IN S or Ins. This also implies that task names are case insensitive 2 Commands The following is a description of the commands that your program must support 1. Insert Task Command: The syntax for the insert task command is as follows ins str date where ins is the name of the command, str is the name of the task being inserted into the list, and date represents a date where the task should be completed by, i.e the deadline of the task. The behavior of the ins command is described by the following cases (a) CaseI: If the task described by str is already contained in the list, but the deadline date indicated is di_erent, then the program should update the date_eld of the already existing node to be the new date. The rest of the list should remain unchanged. Note: If the dates are the same, then no change to the node should take place (b) Case ll If the task described by str is not contain in the list, then a new node should be created and added to the list. The deadline for this new task is indicated by date Page 1 of 4 Nota Bene: In any case, the ins command does not produce any output 2. Complete Task Command: The syntax for the complete task command is as follows: com str where com is the name of the command and str is the name of a task. If the task indicated by str is contained in the list, then the application should mark that task as completed by updating the necessary elds, i.e. the completed_eld and the completed date_eld. The completed date_eld should be set to the current day. If the task is not contained in the list, then the program should display an error message No such task." 3. Print List Command: The syntax for the print list command is given as follows plt where plt is the name of the command. If the user issues this command, then the program should print every task currently contained in the list along with the deadline, and if the task is completed or not. Each task should be displayed on a line by itself in the following fomat Name, Deadline, Completed where Name is the name of the task, Deadline is the deadline of the task, and Completed is lyes" if the task is completed, or Ino" if the task has not yet been completed 4. Clean List Command: The syntax for this command is as follows where cin is the name of the command. The clean command must remove from the list every completed task. The remaining tasks should not be modi_ed 5. Today's Tasks Command The syntax for this command is as follows where tdy is the name of the command. If the user enters this command, then the program should only display the tasks with deadline matching the current date. The output format is the same as that for the print list command 6. Save List Command The syntax for the save list command is as follows sve where sve is the name of the command. If the user enters this command, then the current list of tasks must be saved to a text_le called tasks.dat. The_le should contain all of the infomation necessary to reconstruct the task list, i.e all of the data for each task. 7. Load List Command:The syntax for the load list command is as follows lod where lod is the name of the command. If the user enters this command, then the program should build a linked list of tasks using the tasks dat_le. The behavior of this command is described by the following cases Page 2 of 4 (a) Case l: If the tasks.dat _le does not exist or is empty, then the program should display an appro- priate error message and continue processing further commands. The list maintained by the program should not be modi ed (b) Casell: If the tasks dat _le exists and contains infomation for a task list, then the program should construct a new linked list of tasks corresponding to the_le. The current linked list of tasks should be overidden. 8. Exit Coma: The syntax for the exit command is as follows: ext where ext is the name of the command. If the user issues this command, then the program should shut down 3 Information Regarding Dates Your program must use the Java Date library and necessary supporting libraries for maintaining dates. Infor mation regarding this class can be found here https://docs.oracle.com/javase/7/docs/apijava/util/Date html The fomat for input and output of dates is given by the following pattem: where YYY Y indicates a year using four digits, e.g. 2019, MM indicates a numeric month using two digits, e.g February is indicated by 02 and October is indicated by 10, and DD is two digit numeric day, ie. the th of the month is indicated by 05. For example, the date February 15, 2019 is represented by the string 2019-02-15 You may assume that all dates presented as input are in the correct format and are valid dates. In particular, you do not need to perform any emor checking on dates gi ven as input. However, you must ensure that all dates written as output are in the above format No other information regarding the date need be displayed or accounted for 4 Program Outline The following is a general summary of the behavior of the program 1. Read first command from the user 2. WHILE (command end) 3. process command 4. execute command 5. display output (if any) 6. read next command 7 5 Structural Requirements Your program is required to implement at least the three following classes. The class names must be exactly as indicated in each description: 1. Driver Class: This class should handle reading the user's input, parsing the users input, and constructing a linked list object. The name of this class must be TaskDriver Page 3 of 4 2. Task Node Class: This class should represent a node of the linked list. It must contain_elds for the relevant data and appropriate getters and setters. The name of this class must be TaskNode 3. Task List Class: This class should represent the linked list of tasks. The eld for the head pointer should be contained here, along with all of the methods needed to execute the commands described in the commands section above. The name of this class must be TaskList You are required to write an interactive program that reads commands from the user, executes the c omm ands and displays results (if nec essary) to the user. The program must continue to read and process commands from the user until the exit command is given if an unrecognized command is given, then the program should print the error message: Unrecognized Command, and continue to read input Your program is required to maintain a linked list where each node contains the following data 1. Task: A string representing a task to be completed. Throughout this application, you may assume that each task is described by a string containing no white space characters 2. Date: A date for which the task must be completed by. Details regarding the format for dates can be found below 3. Complete: A Boolean_eld that indicates if the task has been completed or not 4. Completed Date: A_eld that indicates the date that the task was completed. If the task is actve then this eld should remain null. Thus, your program implements a lto-do lit application. The program tracks tasks to be completed, the date when the task must be completed by, and if the task has yet been completed. The commands (described below) are used to add tasks to the list, mark a task as completed, update the deadline of a task, and so on Additionall,y your program will also support saving the list of tasks to a_le so that the list can be recreated for successive runs of the program. The linked list must also satisfy the following important property Property 1: All of the tasks contained in the list are unique Furthermore, for all applicable input, your program should be case insensitive. For example, the c omm and ins should be recognized also as IN S or Ins. This also implies that task names are case insensitive 2 Commands The following is a description of the commands that your program must support 1. Insert Task Command: The syntax for the insert task command is as follows ins str date where ins is the name of the command, str is the name of the task being inserted into the list, and date represents a date where the task should be completed by, i.e the deadline of the task. The behavior of the ins command is described by the following cases (a) CaseI: If the task described by str is already contained in the list, but the deadline date indicated is di_erent, then the program should update the date_eld of the already existing node to be the new date. The rest of the list should remain unchanged. Note: If the dates are the same, then no change to the node should take place (b) Case ll If the task described by str is not contain in the list, then a new node should be created and added to the list. The deadline for this new task is indicated by date Page 1 of 4 Nota Bene: In any case, the ins command does not produce any output 2. Complete Task Command: The syntax for the complete task command is as follows: com str where com is the name of the command and str is the name of a task. If the task indicated by str is contained in the list, then the application should mark that task as completed by updating the necessary elds, i.e. the completed_eld and the completed date_eld. The completed date_eld should be set to the current day. If the task is not contained in the list, then the program should display an error message No such task." 3. Print List Command: The syntax for the print list command is given as follows plt where plt is the name of the command. If the user issues this command, then the program should print every task currently contained in the list along with the deadline, and if the task is completed or not. Each task should be displayed on a line by itself in the following fomat Name, Deadline, Completed where Name is the name of the task, Deadline is the deadline of the task, and Completed is lyes" if the task is completed, or Ino" if the task has not yet been completed 4. Clean List Command: The syntax for this command is as follows where cin is the name of the command. The clean command must remove from the list every completed task. The remaining tasks should not be modi_ed 5. Today's Tasks Command The syntax for this command is as follows where tdy is the name of the command. If the user enters this command, then the program should only display the tasks with deadline matching the current date. The output format is the same as that for the print list command 6. Save List Command The syntax for the save list command is as follows sve where sve is the name of the command. If the user enters this command, then the current list of tasks must be saved to a text_le called tasks.dat. The_le should contain all of the infomation necessary to reconstruct the task list, i.e all of the data for each task. 7. Load List Command:The syntax for the load list command is as follows lod where lod is the name of the command. If the user enters this command, then the program should build a linked list of tasks using the tasks dat_le. The behavior of this command is described by the following cases Page 2 of 4 (a) Case l: If the tasks.dat _le does not exist or is empty, then the program should display an appro- priate error message and continue processing further commands. The list maintained by the program should not be modi ed (b) Casell: If the tasks dat _le exists and contains infomation for a task list, then the program should construct a new linked list of tasks corresponding to the_le. The current linked list of tasks should be overidden. 8. Exit Coma: The syntax for the exit command is as follows: ext where ext is the name of the command. If the user issues this command, then the program should shut down 3 Information Regarding Dates Your program must use the Java Date library and necessary supporting libraries for maintaining dates. Infor mation regarding this class can be found here https://docs.oracle.com/javase/7/docs/apijava/util/Date html The fomat for input and output of dates is given by the following pattem: where YYY Y indicates a year using four digits, e.g. 2019, MM indicates a numeric month using two digits, e.g February is indicated by 02 and October is indicated by 10, and DD is two digit numeric day, ie. the th of the month is indicated by 05. For example, the date February 15, 2019 is represented by the string 2019-02-15 You may assume that all dates presented as input are in the correct format and are valid dates. In particular, you do not need to perform any emor checking on dates gi ven as input. However, you must ensure that all dates written as output are in the above format No other information regarding the date need be displayed or accounted for 4 Program Outline The following is a general summary of the behavior of the program 1. Read first command from the user 2. WHILE (command end) 3. process command 4. execute command 5. display output (if any) 6. read next command 7 5 Structural Requirements Your program is required to implement at least the three following classes. The class names must be exactly as indicated in each description: 1. Driver Class: This class should handle reading the user's input, parsing the users input, and constructing a linked list object. The name of this class must be TaskDriver Page 3 of 4 2. Task Node Class: This class should represent a node of the linked list. It must contain_elds for the relevant data and appropriate getters and setters. The name of this class must be TaskNode 3. Task List Class: This class should represent the linked list of tasks. The eld for the head pointer should be contained here, along with all of the methods needed to execute the commands described in the commands section above. The name of this class must be TaskList

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions