Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Java class with the following properties and methods: Date class: The class and file names are both Date. Properties: Year e.g. 2021 Month

Create a Java class with the following properties and methods:

Date class:

The class and file names are both Date.

Properties:

  • Year e.g. 2021

  • Month e.g. December

  • Day e.g. 25

Methods:

  • accessor methods (aka getters) e.g. returns 2021, etc

  • getDate() method which returns a String version of the date in the form of March 15, 1980

Calendar class:

The class and file names are both Calendar.

Properties:

  • ArrayList called years of the Integers from 1910 to 2025 (Integers)

  • Array called months of all twelve month names (Strings: e.g. January, February, )

  • ArrayList called days of the Integers 1 to 30, inclusive (Integers)

  • HashMap called dates whose key is an Integer and value is a Date (see below)

Constructor:

The constructor must do the following:

  • Used nested loops (loop inside a loop inside a loop) as follows:

    • Use a for-each loop to iterate through the years

    • Use a for loop to iterate through the months

    • Use an iterator to iterate through the days

  • to create a Date object for every date from January 1, 1910 until December 30, 2025 (each month will have 30 days)

  • and store each Date object in the HashMap dates instance variable. January 1 1910 has key 1, January 2 1910 has key 2, , all the way up to December 30 2025 which has key 41760.

Methods:

  • printCalendar() prints each Date in the calendar by using the dates objects keySet() method with a for-each loop, calling the Dates getDate() method.

Main class:

The class and file names are both Main.

Contains the main method, which creates a Calendar object and calls its printCalendar() method which gives the following output:

1: January 1, 1910

2: January 2, 1910

3: January 3, 1910

4: January 4, 1910

5: January 5, 1910

...

14458: February 28, 1950

14459: February 29, 1950

14460: February 30, 1950

14461: March 1, 1950

14462: March 2, 1950

14463: March 3, 1950

14464: March 4, 1950

...

30239: December 29, 1993

30240: December 30, 1993

30241: January 1, 1994

30242: January 2, 1994

...

41757: December 27, 2025

41758: December 28, 2025

41759: December 29, 2025

41760: December 30, 2025

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

with explanations thx

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago