Write a class named month the class should have an int


Question: 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 subsequent methods:

* 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 consructor 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 shuold set monthNumber to 1.

* A getmonthNumber method that returns the value in the monthNumber field.

* A getmonthNumber 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 equal's method that accept 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.

* A greaterThan method that accepts a Moth object as an argument. If the calling object's monthNumber field is greater than the 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 the argument's monthNumber field, this method should return true. Otherwise, it should return false.

Make this program using java programming. Make this application in simple way.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a class named month the class should have an int
Reference No:- TGS0946515

Expected delivery within 24 Hours