(Solved) : Month Class Write Class Named Month Class Int Field Named Monthnumber Holds Number Month E Q37186724 . . .
Month Class Write a class named Month. The class should have anint field named monthNumber that holds the number of the month. Forexample, January would be 1, February would be 2, and so forth. Inaddition, provide the following methods:
- A no-arg constructor that sets the monthNumber field to 1.
- A constructor that accepts the number of the month as anargument. It should set the monthNumber field to the value passedas the argument. If a value less than 1 or greater than 12 ispassed, 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 themonthNumber field to the correct corresponding value.
- A setMonthNumber method that accepts an int argument, which isassigned to the monthNumber field. If a value less than 1 orgreater than 12 is passed, the method should set monthNumber to1.
- A getMonthNumber method that returns the value in themonthNumber field.
- A getMonthName method that returns the name of the month. Forexample, if the monthNumber field contains 1, then this methodshould return “January”.
- A toString method that returns the same value as thegetMonthName method.
- An equals method that accepts a Month object as an argument. Ifthe argument object holds the same data as the calling object, thismethod should return true. Otherwise, it should return false.
- A greaterThan method that accepts a Month object as anargument. If the calling object’s monthNumber field is greater thanthe argument’s monthNumber field, this method should return true.Otherwise, it should return false.
- A lessThan method that accepts a Month object as an argument.If the calling object’s monthNumber field is less than theargument’s monthNumber field, this method should return true.Otherwise, it should return false.
Expert Answer
Answer to Month Class Write a class named Month. The class should have an int field named monthNumber that holds the number of the…
OR