Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Month class. Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example,

image text in transcribedimage text in transcribed

Month class. Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example, January would be 1, February would be 2, and so forth. In addition, provide the following methods: the following methe 1, February A no-arg constructor that sets the monthNumber field to 1. A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than 1 or greater than 12 is passed, the constructor should set monthNumber to 1. A constructor that accepts the name of the month, such as "January" or "February" as an argument. It should set the monthNumber field to the correct corresponding value. A setMonthNumber method that accepts an int argument, which is assigned to the monthNumber field. If a value less than 1 or greater than 12 is passed, the method should set monthNumber to 1 A getMonthNumber method that returns the value in the monthNumber field. A getMonth Name method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January" A toString method that returns the same value as the getMonthName method. An equals method that accepts a Month object as an argument. If the argument object holds the same data as the calling object, this method should return true. Otherwise, it should return false. Use the MonthTest Class attached below to test the Month class methods. You need to complete the code. MonthTest.java

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Discuss relationships among objectives, strategies, and policies.

Answered: 1 week ago

Question

=+1. To understand the concept and process of performance appraisal

Answered: 1 week ago