Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a blueprint class (Month) for driver class (MonthDemo) In JAVA . must work with provided Driver class. ***********DRIVER CLASS****************** /** This program demonstrates a

create a blueprint class (Month) for driver class (MonthDemo) In JAVA. must work with provided Driver class.

***********DRIVER CLASS******************

/**

This program demonstrates a solution to the

Month Class programming challenge.

*/

public class MonthDemo

{

public static void main(String[] args)

{

// Use the no-arg constructor.

Month m = new Month();

System.out.println("Month " + m.getMonthNumber() +

" is " + m);

// Set the month number to the values 2 through 12

for (int i = 2; i <= 12; i++)

{

m.setMonthNumber(i);

System.out.println("Month " + m.getMonthNumber() +

" is " + m);

}

// Use the 2nd constructor to create two objects.

Month m1 = new Month(10);

Month m2 = new Month(5);

System.out.println("Month " + m1.getMonthNumber() +

" is " + m1);

System.out.println("Month " + m2.getMonthNumber() +

" is " + m2);

// Test for equality.

if (m1.equals(m2))

System.out.println(m1 + " and " + m2 + " are equal.");

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);

}

}

**************OUTLINE FOR BLUEPRINT*********************

(what I have so far)

public class Month {

int monthNumber=0;

Month(){

monthNumber =1;

}

Month(int m){

monthNumber =m;

if (m<0 || m>12) {

monthNumber =1;

}

}

Month(String months){ // get input in and output name of month based on what number correspondes to that month

if (months.equals("January")){

monthNumber =1;

for (int i = 0; i <12;i++)

monthNumber = months[i];

}

}

public String getMonthName() {

return name;

}

public String toString() {

return "";

}

public boolean equals() {

return false;

}

public boolean greaterThan(String Month) {

return false;

}

}//end of program

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions