Question: please who can help with this question in Java Thanks Further instructions: Include a copy constructor. The demo class can look like the following: //

please who can help with this question in Java Thanks

please who can help with this question in Java Thanks Further instructions:

Further instructions: Include a copy constructor.

The demo class can look like the following:

// Use different constructors to create two objects

Month m1 = new Month(10); Month m2 = new Month("May");

// Test for equality. if (m1.equals(m2)) System.out.println(m1 + " and " + m2 + " are the same month."); else System.out.println(m1 + " and " + m2 + " are NOT equal.");

// Is m1 greater than m2? if (m1.greaterThan(m2)) System.out.println(m1 + " is greater than " + m2); else System.out.println(m1 + " is NOT greater than " + m2);

// Is m1 less than m2? if (m1.lessThan(m2)) System.out.println(m1 + " is less than " + m2); else System.out.println(m1 + " is NOT less than " + m2);

// Use copy constructor Month m3 = new Month(m2);

// Test for equality. if(m3.equals(m2)) System.out.println(m3 + " and " + m2 + " are the same month."); else System.out.println(m3 + " and " + m2 + " are NOT equal.");

5. 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: 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 month Number field to the value passed as the argument. If a value less than 1 or greater than 12 is passed, the constructor should set month Numberto 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 set Month Number 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 get Month Number method that returns the value in the monthNumber field. A get MonthName 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 get MonthName 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. 554 Chapter 8 A Second Look at Classes and Objects A greater than method that accepts a Month 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 less Than method that accepts a Month object as an argument. If the calling object" monthNumber field is less than the argument's monthNumber field, this method should return true. Otherwise, it should return false

Step by Step Solution

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 Databases Questions!