Question
Problem Description Develop a tool to keep track of events a basic electronic planner of sorts. The Planner will be able to add events, delete
Problem Description
Develop a tool to keep track of events a basic electronic planner of sorts. The Planner will be able to add events, delete events and view events either for a specific date or for seven days starting at a specific date. The planner is able to calculate how many days exist between events. An Event will be stored in an array (set maximum size for now to be 10). There can only be one Event for a given date. Sorting, deleting and retrieving elements (in this case, the elements are references to Event objects) efficiently in an array will be a major topic in your third semester Data Structures course; for now, events will be stored in an array and do not need to be sorted. This means we will just search sequentially through the array. Every Event will contain a date (day, month, year) and an activity description (String). All input entered from the keyboard must be fully edited for valid data. In the case of this assignment, if a user attempts to enter data that is outside of the appropriate range, by default the field will be set to the first day, month or year of the acceptable range of values. For example if a user attempts to set a day to 34, it will automatically be set to 1. NOTE: Only Planner interacts with the user, no other classes should use Scanner or println (etc.)
Assign1 contains only a main method, which instantiates one Planner and calls runMenu().
Planner has a private int constant which is used for the maximum amount of events, an array for Event references (10 references), an int and an OurDate reference, one constructor and six methods:
runMenu() - shows the menu, interacts with the user for menu selection, loops till they exit.
addEvent().
verifies that the maximum number of events is already in the Planner
loops through the array to confirm that an event for the date specified is not already taken.
If there is not already an event on the date specified, add the event to the array and add one to the numEvents counter.
enterDate() fetches the date from the user and assigns values to the fields of each reference by invoking methods of the OurDate class.
displayOneDay() - displays the event for the date specified.
displaySevenDays() displays seven days of events by invoking displayOneDay() seven times, starting with the event with the date specified.
deleteEvent()
loops through the events array, searching for event by the date.
If the event is found, delete it and move all the event references up one, so as not to leave a null element in the middle of the array. Remove one element from the numEvents counter.
Event has an OurDate reference, a String reference, three constructors and six methods:
Two overloaded setDate() methods.
setDescription().
getDate().
getDescription().
toString() - returns a String representation of the Event reference.
OurDate has three fields, day, month and year, three constructors, and eleven methods:
setDay(), setMonth(), setYear(), each must verify that the day, month or year respectively is valid.
getDay(), getMonth(), getYear(), returns day, month or year, respectively.
isEqual() - compares two dates to see if they are equal..
toString() - returns a String representation of the OurDate reference.
addOne() adds one day to the current date, checks for boundaries such as last day month, year, etc..
isLeapYear() - determines if the year specified is a leap year or not you may use an existing algorithm (found online ?) for this, BUTbe certain to reference the source in a comment.
calculateDays() - calculates the amount of days from a base year (in this case January 1, 2000) to the date specified. Invokes the isLeapYear() method.
Heres how it should be formatted (Program Design)
Assign1 class
+main(args: String[]): void
Planner class
- MAXEVENTS: int = 10(readonly)
- Events: Event{}
- numEvents: int
- date:OurDate
+Planner()
+runMenu(): void
+addEvent(): void
+enterDate(): void
+displayOneDay(): void
+displaySevenDays(): void
+deleteEvent(): void
OurDate Class
- day: int
- month: int
- year: int
+OurDate()
+OurDate(day: int, month: int, year: int)
+OurDate(date: OurDate)
+getDay(): int
+getMonth(): int
+getYear(): int
+setDay(day: int): void
+setMonth(month: int): void
+setYear(year: int): void
+isEqual(date: OurDate): Boolean
+addOne(): void
+toString(): String
+calcDays(date :OurDate): int
+isLeapYear(year :int): Boolean
Event Class
- date: OurDate
- description: String
+Event()
+Event(date: OurDate, description: String)
+Event(day: int, month: int, year: int description: String)
+setDate(date: OurDate): void
+setDate(day: int, month: int, year: int): void
+setDescription(description: String: void)
+getDate():OurDate
+getDescription(): String
+toString (): String
Sample Program Run (user inputs):
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 1
Enter event description: rock concert
Enter event date: Enter year: 2015
Enter month: 3
Enter day: 4
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 1
Enter event description: work
Enter event date:
Enter year: 2015
Enter month: 3
Enter day: 3
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 1
Enter event description: dinner at folks
Enter event date:
Enter year: 2015
Enter month: 3
Enter day: 5
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 1
Enter event description: movie night
Enter event date:
Enter year: 2015
Enter month: 3
Enter day: 4
You already have an activity for that date and time...cannot be entered
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 2
Enter date to display:
Enter year: 2015
Enter month: 3
Enter day: 5
Your events for 2015/3/5 are:
2015/3/5 - dinner at folks
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 3
Enter starting date to display:
Enter year: 2015
Enter month: 3
Enter day: 1
Your events for the week starting 2015/3/1 are:
Your events for 2015/3/1 are:
Your events for 2015/3/2 are:
Your events for 2015/3/3 are:
2015/3/3 - work
Your events for 2015/3/4 are:
2015/3/4 - rock concert
Your events for 2015/3/5 are:
2015/3/5 - dinner at folks
Your events for 2015/3/6 are:
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 4
Enter date to delete event from:
Enter year: 2015
Enter month: 3
Enter day: 4
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 3
Enter starting date to display:
Enter year: 2015
Enter month: 3
Enter day: 1
Your events for the week starting 2015/3/1 are:
Your events for 2015/3/1 are:
Your events for 2015/3/2 are:
Your events for 2015/3/3 are:
2015/3/3 - work
Your events for 2015/3/4 are:
Your events for 2015/3/5 are:
2015/3/5 - dinner at folks
Your events for 2015/3/6 are:
Make a selection:
1. Add event to planner
2. Display event for a day
3. Display events for a week
4. Delete an event
0 to quit: 0
Goodbye
Step 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