(Solved) : General Requirements Create Programs Good Programming Style Form Using Proper Blank Spaces Q29501818 . . .
General Requirements:
• You should create your programs with good programming style andform using proper blank spaces, indentation and braces to make yourcode easy to read and understand;
• You should create identifiers with sensible names;
• You should make comments to describe your code segments wherethey are necessary for readers to understand what your code intendsto achieve.
• Logical structures and statements are properly used for specificpurposes.
• Read the assignment specification carefully, and make sure thatyou follow whatever directed in this assignment. In everyassignment that you will submit in this subject, you must put thefollowing information in the header of your assignment otherwise itwill not be marked:
/*——————————————————
My name:
My subject code:
My student number:
My email address:
Assignment number: 3
——————————————————-*/
Objectives
By designing, debugging and testing a menu driven Java program thatmanage a To-Do list, you will learn how to use the
1. Selection statements, i.e., if … else, switch…case,
2. Repetition statement, i.e., while, do…while,
3. ArrayList,
4. Multiple classes.
Background
A task indicates an event that shall be completed within aparticular time. Usually, a task contains four attributes, i.e.,the title, the date, the time, and the location. A To-Do list canmanage all tasks by adding and deleting tasks. In this assignment,you are asked to design and implement a simple To-Do list programby using Java.
Programming Fundamentals – 2/8 –
Tasks
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
+ ToDoList()
+ getSortedList(): Task[]
+ addTask(Task): void
+ deleteTask(int): void
+ deleteAllTasks(): void
+ printList(Task[]): void
– displayMenu(): void
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 shownin the UML class
diagrams above. You are NOT allowed to modify the filed data andthe 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) isthe constructor with three
arguments to indicate the day, month, year;
c. The toString() converts the data that is stored in the threedata 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 threedata fields is earlier than a
date provided as the method argument. Otherwise, it returnsfalse;
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 theconstructor with two
arguments to indicate the minute, hour;
c. The toString() converts time that is stored in two data fieldsof type int into a String
in the format of “hh:mm”;
d. The isEariler(Time) returns true if the current time is earlierthan 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 task’s scheduleis 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 bythe program and can’t
be modified.
5. Class ToDoList:
a. There is only one data field, which is list (ArrayList). Thedata field list
contains a list of tasks in the stored To-Do list. The list can bemodified.
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 listbased on the ascending
order of their date and time, and return the sorted tasks in an 1-Darray;
e. The addTask(Task) will add a new task to the stored To-Dolist;
f. The deleteTask(int) will delete a task from the stored To-Dolist based on the given
taskID (int);
g. The deleteAllTasks() will delete all tasks in the stored To-Dolist;
h. The printList(Task[]) will display all tasks in a given 1-D taskarray 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, collectsuser’s selection and
executes corresponding actions. The menu should look likebelow.
#########################
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 userto make a
selection. The user should input the index of one action, and theprogram should
execute the corresponding action (You must use the swith…casestatement to
implement this process).
– For input 1, it will ask user to input the information for a newtask (i.e., title,
date, time, location, the system will automatically assign thetaskID to each
new task. Hint: The size() in class ArrayList can return thecurrent element
number in the ArrayList), and add the new task to the stored To-Dolist.
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 theuser to input a
task ID and then delete the corresponding task from the storedTo-Do list.
Finally, it will display the updated and sorted list.
– For input 4, it will delete all tasks in the stored To-Do listand indicate the list
is empty.
– For input 5 or others, it will display the farewell informationand terminate
the program.
The menu should be continually displayed (by using the while ordo…while loop)
until the user decide to terminate the program by selecting theoption 5 from the
menu. Please see the given example for details.
Example of the program output (The user’s inputs are shown inblue)
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 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 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 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:
——————————————–
* 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 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:
———————————————
* 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:
———————————————
* 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!
Expert Answer
Answer to General Requirements Create Programs Good Programming Style Form Using Proper Blank Spaces Q29501818 . . .
OR