Question
Objectives By designing, debugging and testing a menu driven Java program that manage a To-Do list, you will learn how to use the 1. Selection
Objectives By designing, debugging and testing a menu driven Java program that manage a To-Do list, you will learn how to use the 1. Selection statements, i.e., if else, switchcase, 2. Repetition statement, i.e., while, dowhile, 3. ArrayList, 4. Multiple classes.
Background A task indicates an event that shall be completed within a particular time. Usually, a task contains four attributes, i.e., the title, the date, the time, and the location. A To-Do list can manage all tasks by adding and deleting tasks. In this assignment, you are asked to design and implement a simple To-Do list program by using Java. Classes are as Follows: Date - day: int - month: int - year: int + Date() + Date(int, int, int) + getDay(): int + getMonth(): int + getYear(): int + setDay(int): void + setMonth(int): void + setYear(int): void + toString(): String + isEariler(Date): boolean
ToDoList - list: ArrayList + main(String[]): void (ALSO IS STATIC) + ToDoList() + getSortedList(): Task[] + addTask(Task): void + deleteTask(int): void + deleteAllTasks(): void + printList(Task[]): void + getTaskNumber(): int - displayMenu(): void (ALSO STATIC)
Time - hour: int - min: int + Time() + Time(int, int) + getHour(): int + getMin(): int + setHour(int): void + setMin(int): void + toString(): String + isEarlier (Time): boolean
Task - time: Time - date: Date - title: String - location: String - taskID: int + Task() + Task(Time, Date, String, String) + getTime(): Time + getDate(): Date + getTitle(): String + getLocation(): String + getTaskID(): int + setTime(Time): void + setDate(Date): void + setTitle(String): void + setLocation(String): void + printTask(): void + isEarlier(Task): boolean
1. Implement the classes Date, Time, Task and ToDoList as shown in the UML class diagrams above. You are NOT allowed to modify the filed data and the functions in all class diagrams.
2. Class Date: a. There are three data fields of type int, which are day, month, year; b. Date() is the default constructor, and Date(int, int, int) is the constructor with three arguments to indicate the day, month, year; c. The toString() converts the data that is stored in the three data fields of type int into a String in the format of dd/mm/yyyy; d. The isEariler(Date) returns true if the date stored in three data fields is earlier than a date provided as the method argument. Otherwise, it returns false; e. The get functions are accessors of the three data fields; f. The set functions are mutators of the three data fields.
3. Class Time: a. There are two data fields of type int, which are min, hour; b. Time() is the default constructor, and Time(int, int) is the constructor with two arguments to indicate the minute, hour; c. The toString() converts time that is stored in two data fields of type int into a String in the format of hh:mm; d. The isEariler(Time) returns true if the current time is earlier than time provided as the method argument. Otherwise, it returns false; e. The get functions are accessors of the two data fields; f. The set functions are mutators of the two data fields.
4. Class Task: a. There are five data fields, which are time (Time), date (Date), title (String), location (String), taskID (int); b. Task() is the default constructor, and Task(Time, Date, String, String, int) is the constructor with five arguments to indicate the time, date, title, location, taskID; c. The printTask() prints out the current task in the format of * Task ID: title, dd/mm/yyyy, hh:mm, location; d. The isEariler(Task) returns true if the current tasks schedule is earlier than a given task from the argument. Otherwise, it returns false; e. The get functions are accessors of the four data fields, i.e., time (Time), date (Date), title (String), location (String); f. The set functions are mutators of the four data fields, i.e., time (Time), date (Date), title (String), location (String); g. The data field taskID (int) will be automatically assigned by the program and cant be modified.
5. Class ToDoList: a. There is only one data field, which is list (ArrayList). The data field list contains a list of tasks in the stored To-Do list. The list can be modified. b. The main(String[]) is the entry of the program; c. The ToDoList() is the default constructor; d. The getSortedList() will sort all tasks in the stored To-Do list based on the ascending order of their date and time, and return the sorted tasks in an 1-D array; e. The addTask(Task) will add a new task to the stored To-Do list; f. The deleteTask(int) will delete a task from the stored To-Do list based on the given taskID (int); g. The deleteAllTasks() will delete all tasks in the stored To-Do list; h. The getTaskNumber() method returns the number of total tasks in the To-Do list i. The printList(Task[]) will display all tasks in a given 1-D task array in the follow
format:
--------------------------------------------- * Task ID: title, dd/mm/yyyy, hh:mm, location * Task ID: title, dd/mm/yyyy, hh:mm, location . . . --------------------------------------------- i. The displayMenu() displays the menu of the program, collects users selection and executes corresponding actions. The menu should look like below. ######################### 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program ######################### Please select an action from above: The program should display the menu at beginning and ask the user to make a selection. The user should input the index of one action, and the program should execute the corresponding action (You must use the swithcase statement to implement this process). - For input 1, it will ask user to input the information for a new task (i.e., title, date, time, location, the system will automatically assign the taskID to each new task. Hint: The size() in class ArrayList can return the current element number in the ArrayList), and add the new task to the stored To-Do list. Finally, it will display the sorted tasks. - For input 2, it will display the sorted tasks directly. - For input 3, it will display the sorted tasks first and ask the user to input a task ID and then delete the corresponding task from the stored To-Do list. Finally, it will display the updated and sorted list. - For input 4, it will delete all tasks in the stored To-Do list and indicate the list is empty. - For input 5 or others, it will display the farewell information and terminate the program. The menu should be continually displayed (by using the while or dowhile loop) until the user decide to terminate the program by selecting the option 5 from the menu. Please see the given example for details.
SAMPLE OUTPUT:
javac ToDoList.java java ToDoList 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program : Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program 1: Add a task 2: List al tasks 3: Delete a task 4: Delete all tasks 5: Exit the program 1 Please select an action from above: 1 Please input the new task title: Meet John Pease input the new task date (dd mm yyyy): 05 05 2018 Please input the starting time: (hh mm): 16 46 Please input the location: Uni Bar Task 3 is added. The To-Do list is follows: -Please select an action from above: 2 The To-Do list is follows: Please select an action from above: 1 Please input the new task title: CSIT111_Exam Pease input the new task date (dd mm yyyy): 12 06 2018 Please input the starting time: (hh mm): 10 30 Please input the location: UOW Task 1 is added. The To-Do list is follows: Task 2: Dinner, 1/5/2018, 18:30, Lagoon Task 3: Meet John, 5/5/2018, 16:45, Uni Bar Task 2: Dinner, 1/5/2018, 18:30, Lagoon Task 3: Meet John, 5/5/2018, 16:45, Uni_Bar Task 1: CSIT111 Exam, 12N6/2018, 10:30, UOVW 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program Task 1: CSIT111 Exam, 12/6/2018, 10:30, UOW 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program Please select an action from above: 4 All tasks are deleted. The To-Do is empty 4 Please select an action from above: 1 Please input the new task title: Dinner Pease input the new task date (dd mm yyyy): 01 05 2018 Please input the starting time: (hh mm): 18 30 Please input the location: Lagoon Task 2 is added. The To-Do list is follows: 1: Add a task 2: List all tasks 3: Delete a task 4: Delete all tasks 5: Exit the program Please select an action from above: 3 Task 2: Dinner, 1/5/2018, 18:30, Lagoon Task 3: Meet John, 5/5/2018, 16:45, Uni_Bar Task 1: CSIT111 Exam, 1216/2018, 10:30, UOW Please select an action from above: 5 Thanks for using my To-Do List program, Goodbye! Please input the task ID to be deleted: 1 Task 1 is deleted. The To-Do list is follows: Task 2: Dinner, 1/5/2018, 18:30, Lagoon Task 1: CSIT111 Exam, 12/6/2018, 10:30, UOw Task 2: Dinner, 115/2018, 18:30, Lagoon Task 3: Meet John, 55/2018, 16:45, Uni BarStep 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