Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Programming Fundamentals - 1/8 -

Tasks

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

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

Time

- hour: int - min: int

+ Time() + Time(int, int) + getHour(): int + getMin(): int + setHour(int): void + setMin(int): void + toString(): String + isEarlier (Time): boolean

ToDoList

- list: ArrayList

+ main(String[]): void + ToDoList() + getSortedList(): Task[] + addTask(Task): void + deleteTask(int): void + deleteAllTasks(): void + printList(Task[]): void - displayMenu(): void

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.

Class Date:

There are three data fields of type int, which are day, month, year;

Date() is the default constructor, and Date(int, int, int) is the constructor with three

arguments to indicate the day, month, year;

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;

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;

The get functions are accessors of the three data fields;

The set functions are mutators of the three data fields.

Class Time:

There are two data fields of type int, which are min, hour;

Time() is the default constructor, and Time(int, int) is the constructor with two

arguments to indicate the minute, hour;

The toString() converts time that is stored in two data fields of type int into a String

in the format of hh:mm;

The is Eariler(Time) returns true if the current time is earlier than the time provided as

the method argument. Otherwise, it returns false; Programming Fundamentals - 2/8 -

The get functions are accessors of the two data fields;

The set functions are mutators of the two data fields.

Class Task:

There are five data fields, which are time (Time), date (Date), title (String), location (String), taskID (int);

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;

The printTask() prints out the current task in the format of * Task ID: title,dd/mm/yyyy, hh:mm, location;

The is Eariler(Task) returns true if the current tasks schedule is earlier than a given task from the argument. Otherwise, it returns false;

The get functions are accessors of the four data fields, i.e., time (Time), date (Date), title (String), location (String);

The set functions are mutators of the four data fields, i.e., time (Time), date (Date), title (String), location (String);

The data field taskID (int) will be automatically assigned by the program and cantbe modified.

Class ToDoList:

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.

The main(String[]) is the entry of the program;

The ToDoList() is the default constructor;

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;

The addTask(Task) will add a new task to the stored To-Do list;

The deleteTask(int) will delete a task from the stored To-Do list based on the given

taskID (int);

The deleteAllTasks() will delete all tasks in the stored To-Do list;

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 andexecutes corresponding actions. The menu should look like below.

######################### 1: Add a task 2: List all tasks 3: Delete a task

4: Delete all tasks

Programming Fundamentals

- 3/8 -

5: Exit the program ######################### Please select an action from above:

The program should display the menu at the 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 switch...case 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 do...while loop) until the user decide to terminate the program by selecting the option 5 from the menu. Please see the given example for details.

Example of the program output (The users inputs are shown in blue)

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 ######################### 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 2018Please input the starting time: (hh mm): 10 30 Please input the location: UOW

Programming Fundamentals

- 4/8 -

Task 1 is added. The To-Do list is follows: --------------------------------------------- * 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 ######################### 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 2018Please input the starting time: (hh mm): 18 30 Please input the location: Lagoon Task 2 is added. 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 --------------------------------------------- ######################### 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: 1 Please input the new task title: Meet_John Pease input the new task date (dd mm yyyy): 05 05 2018Please input the starting time: (hh mm): 16 46 Please input the location: Uni_Bar Task 3 is added. The To-Do list is follows:

Programming Fundamentals

- 5/8 -

--------------------------------------------- * Task 2: Dinner, 1/5/2018, 18:30, Lagoon * Task 3: Meet_John, 5/5/2018, 16:45, Uni_Bar * 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 ######################### 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, 12/6/2018, 10:30, UOW --------------------------------------------- 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 3: Meet_John, 5/5/2018, 16:45, Uni_Bar --------------------------------------------- ######################### 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: 2 The To-Do list is follows: ---------------------------------------------

Programming Fundamentals

- 6/8 -

* Task 2: Dinner, 1/5/2018, 18:30, Lagoon * Task 3: Meet_John, 5/5/2018, 16:45, Uni_Bar --------------------------------------------- ######################### 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. ######################### 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: 5 Thanks for using my To-Do List program, Goodbye!

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_2

Step: 3

blur-text-image_3

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

Question

2. The model is credible to the trainees.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago