Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for a JAVA Class in Object Oriented Design, and must use JAVA 8 API features/methods in java.time , java.calendar such as LocalDate, LocalTime,

This is for a JAVA Class in Object Oriented Design, and must use JAVA 8 API features/methods in java.time , java.calendar such as LocalDate, LocalTime, LocalDateTime etc....

-------------------------------------------------

In this assignment, you will design and implement a calendar similar to the one you can find on your phone. The calendar is going to be implemented as a console application.

The initial screen shows the current month looking like this. It also highlights today's date using a pair of brackets. (It is not straightforward to highlight on the console. It is fine to use a pair of brackets for this purpose.)

 March 2019 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [20] 21 22 23 <-- It is ok if this line is sticking out. 24 25 26 27 28 29 30 31 

When the program starts, it loads events from events.txt and populates the calendar with them. The events.txt is a text file of an event you need to prepare ahead of the program execution.

There are two different types of events the program manages: regular and one-time.

  • A regular event is one that is scheduled every week on the same day or days, such as a lecture that meets every Monday and Wednesday.
  • A one-time event is scheduled on a particular date, such as 10/15/19, and doesn't repeat.

In the event.txt file, each event takes up two lines.

  • Regular event The first line contains the name of the event which may contain spaces. The second line consists of a sequence of day abbreviations (SMTWRFA, upper or lower case) followed by a starting date and an ending date of the regular event.
  • One time event The first line contains the name of the event which may contain spaces. The second line consists of a date in the format mm/dd/yy, e.g.3/22/19. There cannot be any spaces within a date description. the date description is followed by a starting time and an ending time. For the starting and ending times, only military 24-hour time will be used for simplicity. For example, 18:15 instead of 6:15 pm The minutes cannot be left off in which case zeros should be specified for the minutes, e.g. 14:00.

Here is a sample events.txt:

CS151 Lecture TR 10:30 11:45 1/24/19 5/9/19 CS157C Lecture MW 11:45 13:15 1/28/19 5/13/19 Interview at Apple 9/28/19 9:30 11:30 Dentist appt 10/3/19 16:15 17:00 Course Committee Meeting F 18:30 20:30 1/25/19 5/13/19 

After loading the events, the program prompts "Loading is done!". The program now displays a main menu with following options: View by, Create, Go to, Event list, Delete, and Quit. After the function of an option is done, the main menu is displayed again for the user to choose the next option.

Select one of the following options: [V]iew by [C]reate, [G]o to [E]vent list [D]elete [Q]uit 

The user may enter one of the letters highlighted with a pair of the bracket to choose an option. For example,

V 

will choose the View by option.

  • [V]iew by The user can choose a Day or a Month view. If a Day view is chosen, the program prints today's date. If there is an event(s) scheduled on that day, display them in the order of start time of the event. With a Month view, it displays the current month and highlights day(s) with a pair of brackets {} if any event scheduled on that day. After a view is displayed, the calendar gives the user three options: P, N, and G, where P, N, and M stand for Previous, Next and Go back to the main menu, respectively. The previous and next options allow the user to navigate the current view back and forth. If the day view was selected, the view goes back (P) and forth (N) by day. If the month view was chosen, the view goes back (P) and forth (N) by month. Here are sample runs:
    [D]ay view or [M]view ? 
    If the user selects D, then today's date is displayed along with scheduled events.
    Thu, March 19, 2019 CS151 Lecture : 10:30 - 11:45 [P]revious or [N]ext or [G]o back to main menu ? 
    If the user selects M, then
     March 2019 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 {19} 20 21 22 23 24 25 26 27 28 29 30 31 [P]revious or [N]ext or [G]o back to main menu ? 
    Note: The following example code segment shows how to print the given date in a specified format.
    LocalDate c = .... DateTimeFormatter formatter = DateTimeFormatter.ofPattern("E, MMM d yyyy"); System.out.println(" " + formatter.format(c)); 
  • [C]reate This option allows the user to schedule an event. The calendar asks the user to enter the title, date, starting time, and ending time of an event. For simplicity, we consider one-time event only for the Create function. Your program should check if a new event is a conflict with existing events. Please stick to the following format to enter data:
    • Title: a string (doesn't have to be one word)
    • date: MM/DD/YYYY
    • Starting time and ending time: 24 hour clock such as 06:00 for 6 AM and 15:30 for 3:30 PM.
  • [G]o to With this option, the user is asked to enter a date in the form of MM/DD/YYYY and then the calendar displays the Day view of the requested date including an event scheduled on that day in the order of starting time.
  • [E]vent list The user can browse scheduled events. The calendar displays all the events scheduled in the calendar in the order of starting date and starting time. An example presentation of events is as follows: (The format of event strings does not have to be exactly like this.)
    2019 Friday March 15 13:15 - 14:00 Dentist Thursday April 25 15:00 - 16:00 Job Interview 2020 ... 
  • [D]elete The user can delete an event from the Calendar. There are three different ways to delete an event: Selected, All and DeleteRegular. Other types of deletion will not be considered for simplicity.
    • [S]elected: the user specifies the date and name of an ONE TIME event. The specific one time event will be deleted.
    • [A]ll: the user specifies a date and all ONE TIME events scheduled on the date will be deleted.
    • [DR]: the user specifies the name of a REGULAR event. The specfied regular event will be deleted.
    [S]elected or [A]ll ? 
    If the user enters S, then the calendar asks for the date and displays all the events scheduled on that date. The program then asks the name of the event to be deleted and deletes the specified event. If there is no such event, the program promotes an error message.
    Enter the date [dd/mm/yyyy] 03/15/2019 13:15 - 14:00 Dentist 17:00 - 17:45 Piano Lesson Enter the name of the event to delete: Dentist The event is deleted. Here is the current scheduled event: 03/17/2018 17:00 - 17:45 Piano Lesson 
  • [Q]uit The program prompts "Good Bye", saves the current events in a file called output.txt, and terminates. The main menu will be displayed after each option is done. It is crucial to have a user friendly interface for the user to enter input. For example, if the calendar needs a date from the user, suggest a specific format of the date for the user to use. Our class grader will be the user to operate your calendar, and you don't want to frustrate the user with a confusing interface.

-----

EXAMPLE ON HOW TO ADVANCE THE MONTH:

/** * Example to show the manipulation of Date and Time information through * */ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Scanner; public class DateTimeExample { public static void main(String [] args) { LocalDate cal = LocalDate.now(); // capture today Scanner sc = new Scanner(System.in); System.out.print("Today: "); printCalendar(cal); while (sc.hasNextLine()) { String input = sc.nextLine(); if (input.equals("p")) { cal = cal.minusMonths(1); // LocalDateTime is immutable printCalendar(cal); } else if (input.equals("n")) { cal = cal.plusMonths(1); // LocalDateTime is immutable printCalendar(cal); } } System.out.println("Bye!"); } public static void printCalendar(LocalDate c) { System.out.print(c.getDayOfWeek()); System.out.print(" "); System.out.print(c.getDayOfMonth()); System.out.print(" "); System.out.println(c.getMonth()); // To print a calendar in a specified format. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("E, MMM d yyyy"); System.out.println(" " + formatter.format(c)); // To figure out the day of week of the 1st day of the given month LocalDate x = LocalDate.of(c.getYear(), c.getMonth(), 1); System.out.println(x.getDayOfWeek() + " is the day of " + c.getMonth() + " 1."); // enum value as it is System.out.println(x.getDayOfWeek().getValue() + " is an integer value corresponding " + " to " + x.getDayOfWeek()); // int value corresponding to the enum value } } 

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions