Create a class called month with the given fields and method

Assignment Help JAVA Programming
Reference no: EM131272991

Assignment

Create a class called Month (java file called Month.java) with the (exact) following fields and methods (these names and caps exactly):

Filed/Method Description

MonthNumber An int field that holds the number of the month

Number Name

1 January

2 February

3 March

4 April

5 May

6 June

7 July

8 August

9 September

10 October

11 November

12 December

Month A no-argument constructor that sets the monthNumber field to 1

Month A contructor that accept the number of the month as an argument (1, 2, etc) and sets the monthNumber field to that value. If a value less than 1 or larger that 12 is passed , the constructor should set monthNumber to 1 Month A contructor that accept the name of the month as an argument ("January", February", etc) and sets the monthNumber field to the corresponding number.

GetMonthNumber A method that returns the monthNumber field value

SetMonthNumber A method that accept an int number as an argument and sets the monthNumber field to that number

GetMonthName A method that returns the name of the month corresponding to the monthNumber field value

SetMonthName A method that accept a string value as an argument (representing the name of the month: "January", February", etc.) and sets the monthNumber field to the

Corresponding number (1, 2, etc) -

Equals A method that accepts a Month object as an argument and returns true if the data from that object (its MonthNumber) is the same as the MonthNumber field or false

otherwise GreaterThan A method that accepts a Month object as an argument and returns true if the data from that object (its MonthNumber) is greater than the MonthNumber field or false

otherwise

LessThan A method that accepts a Month object as an argument and returns true if the data

from that object (its MonthNumber) is less than the MonthNumber field or false

otherwise

You are going to lose points if you do not name the class, the fields, or methods as requested. You should not have a field for the month name: your code should compute the name of the month from the number when needed.

Create a program/project called [YourName]-Assignment6 (replace [YourName] with your actual name) in the same project as the Month.java. You will need to add the class Month to the project and add your code to the project class main method. The program (code) should:

Create three objects: Month1 one using the first constructor (with no arguments) and Month2 using the second constructor with 2 as an argument, and Month3 using the third constructor with "October" as an

Argument.

Use the GetMonthNumber to get the month number from objects Month1, Month2, and Month3 and output the values to the console.

Use the GetMonthName to get the month name from objects Month1, Month2, and Month3 and output the values to the console.

Use the SetMonthNumber to set the Month1 object value to 9.

Use the SetMonthName with argument "September" to set the Month2 object value to 9. - Extra Credit

Use the GetMonthName to get the month name from objects Month1, Month2, and Month3 and output the values to the console.

Use the Equals method of Month1 to compare its value with Month2 value and output the result to the console.

Use the GreaterThan method of Month2 to compare its value with Month3 value and output the result to the console.

Use the LessThan method of Month3 to compare its value with Month1 value and output the result to the console.

Reference no: EM131272991

Questions Cloud

Write a simple text adventure game : For this assignment you will write a simple text adventure game. Within this game the player will travel from room to room choosing which door to traverse through.
Imagine you represent a person : Imagine you represent a person who claims to have been the victim of a breach of contract. Determine the information that you would need to know to best determine if there was a contract.
Half of the variation in personality : Research on genetic influences on personality suggests that more than half of the variation in personality is due to nurture-to life experiences. What life experiences could make someone more conscientious? More agreeable? More neurotic? More extr..
Define and explain ethical theory : Explain how ethical thinking results in practical, moral action. Briefly illustrate how this is applied in your personal life. And Include three or more scholarly resources.
Create a class called month with the given fields and method : Create a class called Month (java file called Month.java) with the (exact) following fields and methods. Create three objects: Month1 one using the first constructor (with no arguments) and Month2.
Describe one evidence claim for and claim against : Describe one (1) evidence claim for and one(1) evidence claim against your chosen topic. The topic is "What are the unconstructive and constructive impacts of technology on the teenagers"?
Certificate of incorporation : ABC Corporation obtained its Certificate of Incorporation (Its Charter) from the State of Delaware. It has its headquarters and most of its employees in the State of Massachusetts. Based upon this scenario, ABC Corporation is considered a Foreign ..
What is a good definition of metaethics : What is a good definition of metaethics? What are the types of issues involved and questions raised by metaethics? Cite your sources from the class readings and other course materials. Just 125 words.
Explain the components of the whistleblower protection act : Explain the components of the Whistleblower Protection Act and describe how it works and What elements of law are important for Luke Sheldon to consider in advancing his case.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a class called salaried

Create a class called Salaried that is derived from Employee. Create a class called Hourly that is also derived from Employee

  Write a program that extends the bankaccount class

To verify the banks total, read the file and write a program using a CarLoan class that extends the BankAccount class (found on page 671 - 672 in the textbook).

  Invoice project - test the invoice application

Test the Invoice Application with an invalid total like $1000 and include the dollar sign. This should cause the application to crash with a runtime error and to display an error message in the Output window. Take a screenshot of the error message..

  Write a program that creates an apartment object and prompts

Create a structure named Apartment that contains data fields to hold the number of bedrooms, the number of bathrooms, and the monthly rent for the apartment.

  Provide a java class named "input" containing method readint

Provide a Java class named "Input" containing the method "readInt" (prototype given below) that displays the prompt string, reads an integer, and tests whether it is between the supplied minimum and maximum. If not, it prints an error message and ..

  Write program that reverses string with the in main function

Write a program that reverses a string with the In themain function, ask the user to enter a string and The entered string can be handled as C-string (or converted to C-string).

  Write a program that takes input of names from user

Write a program that takes input of names from user. Print total names number and all names. NOTE: Solve this problem using ArrayList and Enhanced For Loop. Typical run of the program:Enter a name: (Q to exit)

  What access modifier do you use to restrict access

Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

  Write a java program

Create a "JApplet" that contains two parallel arrays with at least five friends' names and phone numbers. Allow the user to enter either a name or phone number and to click a "JButton" to display the other.

  A meanu driven program which maintain a list of car models

A meanu driven program which will maintain a list of a car models and their price

  How many parameters are supposed to be passed

How many parameters are supposed to be passed to the constructor or how big to create the array - Method Union comparing two different objects?

  Design your own three-stage explicit runge-kutta method

Design your own three-stage explicit Runge-Kutta method with one-step error O(h^4) - Confirm that the global error in your numerical solution is O(h^3).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd