Question: public class Month{ public static void main(String[] args) { Your goal is to create a Month class that encapsulates the concept of month, assuming

Your goal is to create a Month class that encapsulates the concept of month, assuming that a month has a 

 “public class Month{   public static void main(String[] args) {”

Your goal is to create a Month class that encapsulates the concept of month, assuming that a month has a month number attribute. Include a constructor and setter/getter methods for month number, a getter for the month name, a getter for the season, a toString method, and an equals method. Create a MonthCreator class to test all the methods in your class. The UML is shown below: Month -monthNumber: int +Month(m: int) +setMonthNumber(m:int):void +getMonthNumber():int +getMonthName(): String +getSeason(): String +toString(): String +equals(month2:Month):boolean Month Class . Include the monthNumber class field that holds the number of the month. For example, January would be 1, February would be 2, etc. (1 point) 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 the monthNumber to 1. (2 points) 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. (2 points) A getMonthNumber method that returns the value in the monthNumber field. (1 point) A getMonthName method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January". Create an array for the month names. Use the monthNumber field value to pull the correct month name from the array. (4 points) A getSeason method that returns the season based on the month number. Winter would be December, January, and February. Spring would be March, April, and May. Summer would be June, July, and August. Fall would be September, October, and November. (3 points) A toString method that returns the month number, month name, and the season. (2 points) Write a boolean equals method for the Month class that compares the month numbers of 2 month objects to determine if they are the same. (2 points) MonthCreator Class Create 2 month objects including a month numbers. (1 point) Call the toString method for both of these month objects and print the results. (1 point) Call the equals method using the 2 month objects and print the result. (1 point) Example Output: Month Number: 10 Month Name: October Season: Fall

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!