public class Month{ public static void main(String[] args) { Your goal is to create a Month
Fantastic news! We've Found the answer you've been seeking!
Question:
“public class Month{ public static void main(String[] args) {”
Transcribed Image Text:
Your goal is to create a Month class that encapsulates the concept of month, assuming that a month has a month number attribute. Include a constructor and setter/getter methods for month number, a getter for the month name, a getter for the season, a toString method, and an equals method. Create a MonthCreator class to test all the methods in your class. The UML is shown below: Month -monthNumber: int +Month(m: int) +setMonthNumber(m:int):void +getMonthNumber():int +getMonthName(): String +getSeason(): String +toString(): String +equals(month2:Month):boolean Month Class . Include the monthNumber class field that holds the number of the month. For example, January would be 1, February would be 2, etc. (1 point) 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 the monthNumber to 1. (2 points) 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 should set monthNumber to 1. (2 points) A getMonthNumber method that returns the value in the monthNumber field. (1 point) A getMonthName method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January". Create an array for the month names. Use the monthNumber field value to pull the correct month name from the array. (4 points) A getSeason method that returns the season based on the month number. Winter would be December, January, and February. Spring would be March, April, and May. Summer would be June, July, and August. Fall would be September, October, and November. (3 points) A toString method that returns the month number, month name, and the season. (2 points) Write a boolean equals method for the Month class that compares the month numbers of 2 month objects to determine if they are the same. (2 points) MonthCreator Class Create 2 month objects including a month numbers. (1 point) Call the toString method for both of these month objects and print the results. (1 point) Call the equals method using the 2 month objects and print the result. (1 point) Example Output: Month Number: 10 Month Name: October Season: Fall Your goal is to create a Month class that encapsulates the concept of month, assuming that a month has a month number attribute. Include a constructor and setter/getter methods for month number, a getter for the month name, a getter for the season, a toString method, and an equals method. Create a MonthCreator class to test all the methods in your class. The UML is shown below: Month -monthNumber: int +Month(m: int) +setMonthNumber(m:int):void +getMonthNumber():int +getMonthName(): String +getSeason(): String +toString(): String +equals(month2:Month):boolean Month Class . Include the monthNumber class field that holds the number of the month. For example, January would be 1, February would be 2, etc. (1 point) 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 the monthNumber to 1. (2 points) 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 should set monthNumber to 1. (2 points) A getMonthNumber method that returns the value in the monthNumber field. (1 point) A getMonthName method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January". Create an array for the month names. Use the monthNumber field value to pull the correct month name from the array. (4 points) A getSeason method that returns the season based on the month number. Winter would be December, January, and February. Spring would be March, April, and May. Summer would be June, July, and August. Fall would be September, October, and November. (3 points) A toString method that returns the month number, month name, and the season. (2 points) Write a boolean equals method for the Month class that compares the month numbers of 2 month objects to determine if they are the same. (2 points) MonthCreator Class Create 2 month objects including a month numbers. (1 point) Call the toString method for both of these month objects and print the results. (1 point) Call the equals method using the 2 month objects and print the result. (1 point) Example Output: Month Number: 10 Month Name: October Season: Fall
Expert Answer:
Related Book For
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel
Posted Date:
Students also viewed these programming questions
-
I have an assignment which is called SEC 10-K Company Report where, I choose lululemon athletica inc. for my SEC 10-K company. I will send you the link of lululemon athletica inc. SEC 10-K company...
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
Student Bank is an online bank focused on students. In 2022, Student Bank had $100 million in loans it retained and $50 million in pass-through loans. It earned 19% interest and 3% origination fee on...
-
A study of 876 senior citizens shows that participants who exercise regularly exhibit less of a decline in cognitive ability than those who barely exercise at all. From this study, a researcher...
-
An air-conditioner provides 1 kg/s of air at 15C cooled from outside atmospheric air at 35C. Estimate the amount of power needed to operate the air-conditioner. Clearly state all...
-
Juniper Corporation makes three models of insulated thermos. Juniper has $319,000 in total revenue and total variable costs of $165,880. Its sales mix is given below: Thermos A Thermos B Thermos C...
-
Nuts and Cholesterol Several studies have been performed to examine the relationship between nut consumption and cholesterol levels. Here we consider two such studies. In Study 1, participants were...
-
Tiffany Goren started her own consulting firm, Goren Consulting, on May 1, 2010. The trial balance at May 31 is as shown below. In addition to those accounts listed on the trial balance, the chart of...
-
Luccasen Inc., has a market beta of 1.25. The risk-free interest rate is 3%, and the market risk premium is 8%. Given this information, what is the expected return for Luccasen Inc.?
-
Consider the following parlor game to be played between two players. Each player begins with three chips: one red, one white, and one blue. Each chip can be used only once. To begin, each player...
-
Takos Ltd and Janvan Co are negotiating an MNA deal. The two companies need to establish the combined weighted average cost of capital. The information provided includes that Takes Ltd's WACC is 10%...
-
What does consideration of environmental justice say about the use of cost-benefit analysis in the evaluation of environmental projects? Be specific.
-
Explain the following statement: The optimal financial policy depends in an important way on the nature of the firms assets.
-
What is the purpose of industry analysis?
-
Why might conflicts arise between stockholders and debtholders?
-
If one firm is growing rapidly and another is not, how might this distort a comparison of their inventory turnover ratios?
-
solve dy/dx - (4x-y+1)^2 = 0
-
In muscle tissue, the ratio of phosphorylase a to phosphorylase b determines the rate of conversion of glycogen to glucose 1phosphate. Classify how each event affects the rate of glycogen breakdown...
-
Fill in the blanks in each of the following statements: a. If a class contains at least one abstract method, its a(n) class. b. Classes from which objects can be instantiated are called classes. c....
-
List the reasons for entering the blocked state. For each of these, describe how the program will normally leave the blocked state and enter the runnable state.
-
What are abstract methods? Describe the circumstances in which an abstract method would be appropriate.
-
What are some of the issues that should be considered when conducting marketing research?
-
Why do organizations conduct marketing research?
-
What are the different methods of conducting marketing research?
Study smarter with the SolutionInn App