Java

please see the files  

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Name CS117 – Homework 04 – Page 1

Homework 04: Event Calendar

Assigned: Monday, February 26, 2018
Due: Friday, March 12, 2018 at 6:00am

1 Background: Working With Dates

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Keeping track of the current day of the year is a surprisingly complicated task, because of leap
years and time zones and other details that we might not think of. Fortunately, Java comes with
professionally-designed classes for doing this work. The newest version of Java (called either Java
8 or Java 1.8 at different times) includes a brand new class that is especially easy to use, named
LocalDate. If you are not currently using Java 8 / 1.8, you will need to upgrade for this assignment.

You can read the documentation for the LocalTime class at https://docs.oracle.com/javase/
8/docs/api/java/time/LocalDate.html, but I am going to summarize just the most important
features that you will need for this assignment.

This class needs to be imported, just like ArrayList, HashSet, Iterator, and HashMap. But
while all of those classes were in the package java.util, LocalDate is in the package java.time.

Strangely, LocalDate does not have any constructors, and so we cannot create LocalDate
objects in the usual way. But instead, the class has a static method with this signature:

1 public static LocalDate of(int year , int month , int dayOfMonth)

So if I wanted to make an object to store date on which this homework was assigned, I would
do it like this:

1 LocalDate startDate = LocalDate.of(2018 , 2, 26);

Here are the signatures of some of the instance methods the LocalDate class has:

1 public boolean equals(Object other)
2 public int getDayOfMonth ()
3 public DayOfWeek getDayOfWeek ()
4 public int getMonthValue ()
5 public int getYear ()
6 public String toString ()

The third requires a bit of further explanation. It returns a member of another class, DayOfWeek
, which happens to be an enumeration similar to the one I used as an example in class. This class
also needs to be imported from java.time. It has constants named MONDAY, TUESDAY, etc. It also
has a static method with the following signature, that returns MONDAY for 1, TUESDAY for 2, etc:

1 public static DayOfWeek of(int dayOfWeek)

2 Overview

We are going to write a program that helps you keep track of your appointments and events.

Name CS117 – Homework 04 – Page 2

3 Assignment: Event Class

Create an abstract class named Event. It should have a field for the name of the event, and
constructors / methods with the following signatures:

1 public Event(String theName)
2 public String getName ()
3 public abstract boolean isOnDay(LocalDate when)

4 Assignment: OneTimeEvent Class

Create a class named OneTimeEvent for an event that occurs on only a single day. (Example: on
February 28, 2017 Dr. Hogg has a dentist appointment.) It should be a subclass of Event. It
should have a field to store that day, and should have constructors / methods with the following
signatures:

1 public OneTimeEvent(String theName , LocalDate theDate)
2 public boolean isOnDay(LocalDate when)

5 Assignment: MonthlyEvent Class

Create a class named MonthlyEvent for an event that repeats on the same day of every month.
(Example: on the 7th day of every month Dr. Hogg’s recycling is collected.) It should be a subclass
of Event. It should have a field to store the day of the month, and should have constructors /
methods with the following signatures:

1 public MonthlyEvent(String theName , int theDayOfMonth)
2 public boolean isOnDay(LocalDate when)

6 Assignment: WeeklyEvent Class

Create a class named WeeklyEvent for an event that repeats on the same day of every week.
(Example: every Tuesday Dr. Hogg has CS117 lab.) It should be a subclass of Event. It should
have a field to store the day of the week, and should have constructors / methods with the following
signatures:

1 public WeeklyEvent(String theDay , DayOfWeek theDayOfWeek)
2 public boolean isOnDay(LocalDate when)

Name CS117 – Homework 04 – Page 3

7 Assignment: Main Class

Add a main method to the Main class. The main method should have a local variable to store an
ArrayList of Event objects.

The main method should use a loop to repeatedly offer three options to the user: add (a new
event), view (the events for a day), and quit (the program), doing so until they choose to quit.

If the user wants to add a new event, it should ask which type, collect the necessary information,
create a new instance, and add it to the ArrayList. (You should use the getNewEventName method
that I provided.)

If the user wants to view the events for a day, it should ask the year, month number, and day
number, then print the names of the events occurring that day.

See below for an example input / output session.

8 Finishing

Make sure to run Checkstyle on your program, because any complaints that it has will lead to
deductions in your grade.

Also be sure to thoroughly test your program and make sure that it works correctly. I have
included a sample of my program running below. Yours does not need to look exactly the same,
but it should provide the same kind of information and work the same way.

When you are sure that your program is perfect, create an archive file of your CS117-HW04
folder and upload it to Moodle.

9 Sample Session

add (a new event)

view (the events for a day)

quit (the program)

Your choice: add

Event name:

Dentist appointment

Type: (once, monthly, or weekly): once

Year: 2017

Month number: 2

Day: 28

Creating Dentist appointment on 2017-02-28.

add (a new event)
view (the events for a day)
quit (the program)
Your choice: add

Event name:

CS117 Lab

Type: (once, monthly, or weekly): weekly

Weekday number (M = 1, T = 2, …): 2

Name CS117 – Homework 04 – Page 4

Creating CS117 Lab on every TUESDAY.

add (a new event)
view (the events for a day)
quit (the program)
Your choice: add

Event name:

Recycling Pickup

Type: (once, monthly, or weekly): monthly

Day of month: 7

Creating Recycling Pickup on day 7 of each month.

add (a new event)
view (the events for a day)
quit (the program)

Your choice: view

Year: 2017
Month number: 2
Day: 28

Your schedule for 2017-02-28 includes:

Dentist appointment
CS117 Lab
add (a new event)
view (the events for a day)
quit (the program)
Your choice: view
Year: 2017

Month number: 3

Day: 7

Your schedule for 2017-03-07 includes:

CS117 Lab
Recycling Pickup
add (a new event)
view (the events for a day)
quit (the program)
Your choice: view
Year: 2017
Month number: 3

Day: 6

Your schedule for 2017-03-06 includes:

nothing at all!

Name CS117 – Homework 04 – Page 5

add (a new event)
view (the events for a day)
quit (the program)

Your choice: quit

Have a good day!

#BlueJ package file
objectbench.height=76
objectbench.width=686
package.editor.height=400
package.editor.width=560
package.editor.x=106
package.editor.y=162
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.editor.height=700
target1.editor.width=900
target1.editor.x=146
target1.editor.y=210
target1.height=50
target1.name=Main
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=80
target1.x=70
target1.y=10

public synchronized class Main {
public void Main();
public static String getNewEventName();
}

#BlueJ class context
comment0.params=
comment0.target=java.lang.String\ getNewEventName()
comment0.text=\n\ Gets\ the\ name\ of\ a\ new\ event.\n\ Note\:\ I\ created\ this\ method\ so\ that\ you\ don’t\ have\ to\ worry\ about\n\ \ \ \ mixing\ input.next()\ with\ input.nextLine().\n\ If\ the\ only\ input.nextLine()\ is\ here\ in\ my\ method,\ you\ should\ be\ OK.\n\ \n\ @return\ The\ name\ the\ user\ typed\ in.\n
numComments=1

import java.util.Scanner;
/**
* A program that manages a calendar.
*
* @author Chad Hogg
* @version 2017-02-23
*/
public class Main {
/**
* Gets the name of a new event.
* Note: I created this method so that you don’t have to worry about
* mixing input.next() with input.nextLine().
* If the only input.nextLine() is here in my method, you should be OK.
*
* @return The name the user typed in.
*/
public static String getNewEventName() {
Scanner input = new Scanner(System.in);
System.out.print(“Event name: “);
return input.nextLine();
}

}

Calculate your order
275 words
Total price: $0.00

Top-quality papers guaranteed

54

100% original papers

We sell only unique pieces of writing completed according to your demands.

54

Confidential service

We use security encryption to keep your personal data protected.

54

Money-back guarantee

We can give your money back if something goes wrong with your order.

Enjoy the free features we offer to everyone

  1. Title page

    Get a free title page formatted according to the specifics of your particular style.

  2. Custom formatting

    Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.

  3. Bibliography page

    Don’t pay extra for a list of references that perfectly fits your academic needs.

  4. 24/7 support assistance

    Ask us a question anytime you need to—we don’t charge extra for supporting you!

Calculate how much your essay costs

Type of paper
Academic level
Deadline
550 words

How to place an order

  • Choose the number of pages, your academic level, and deadline
  • Push the orange button
  • Give instructions for your paper
  • Pay with PayPal or a credit card
  • Track the progress of your order
  • Approve and enjoy your custom paper

Ask experts to write you a cheap essay of excellent quality

Place an order

Order your essay today and save 30% with the discount code ESSAYHELP