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:
![Your goal is to create a Month class that encapsulates the concept of month, assuming that a month has a](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/651278e6387d6_1695709406977.jpg)
“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...
-
What is the main differences between LAN and WAN?
-
Display a matrix A and an echelon form of A. Find bases for Col A and Nul A, and then state the dimensions of these subspaces. A = ~ 1 1 -2 4 1 0 0 -2 -1 -2 1 0 0 0 1 -6 9 9 5 6 9 5 0 1 0 -3 0 0 5 1...
-
Body mass and metabolic rate. The body mass data in Table 14.1 are given in pounds. There are 2.2 pounds in a kilogram. If we changed the data from pounds to kilograms, how would the mean body mass...
-
Analytics mindset Final Project 4 Gamification Part 1: Background You are the chief technology officer (CTO) of an international bank. A key component of your job is to manage risk within the bank...
-
1 . Determine the fixed cost of Nipponply for a period of one year. in context of the case study "NIPPONPLY: ANALYZING THE FEASIBILITY OF GEOGRAPHICAL EXPANSION"
-
Steam enters a turbine at 9 MPa, 600C, and 60 m/s and leaves at 20 kPa and 90 m/s with a moisture content of 5 percent. The turbine is not adequately insulated, and it estimated that heat is lost...
-
An investor pays $500,000 for a mine that will produce level annual revenue for 17 years. What should the leve annual revenue be (received at the end of each year) if the investor is to receive 4.5%...
-
Low Desert Pottery works makes a variety of pottery products that it sells to retailers. The company uses a job-order costing system in which departmental predetermined overhead rates are used to...
-
ASSESSMENT CPCCBC5002A Monitor costing systems on medium rise building and construction projects Please provide answer to Part 2 - Monitor expenditure for a medium-rise project as per below...
-
Questions 6-8 refer to the same problem A sinusoidal wave with wavelength 2 m and amplitude 5 mm is traveling along the x axis. The wave is traveling in the -x direction at a speed of 2m/s At t = Os,...
-
Consider a circuit where one or more capacitors is discharged through a light bulb filament with a resistance of 3.0 0.3 . Assume that the resistance of the filament is constant (to within the stated...
-
3. For a vibrating string of length with fixed ends, each mode of vibration can be written as where wk ux(x, t) = M* sin(wxt + k) sin(x) and Mk, Ok are determined by initial conditions. For all k >...
-
Gomez Co. had beginning inventory of $1,800 and ending inventory of $1,400. The cost of goods sold was $4,200. Based on this information, Gomez Co. must have purchased Inventory amounting to:...
-
A Alkynes can be made by dehydrohalogenation of vinylic halides in a reaction that is essentially an E2 process. In studying the stereochemistry of this elimination, it was found that...
-
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.
-
If the interest rate is 5%, the 2-year discount factor is close to . a. 0.7 b. 0.9 c. 1.4 d. 1.8
-
If your investment pays the same amount at the beginning of each year for a period of 10 years, the cash flow stream is called a. An annuity. b. A perpetuity. c. A preference dividend. d. None of the...
-
A perpetuity is defined as: a. Equal cash flows at equal intervals of time forever. b. Equal cash flows at equal intervals of time for a specific period. c. Unequal cash flows at equal intervals of...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App