Question
In java Create the class Revenue and TestRevenue that has the following: a. Decompose the RevenueDays class into the class Revenue and test class TestRevenue
In java
Create the class Revenue and TestRevenue that has the following: a. Decompose the RevenueDays class into the class Revenue and test class TestRevenue
b. Revenue:
Constant fields: month names, number of days in common year, number of days in leap year
Private fields: actual days in month, revenue
Constructor: no default ctor
Constructor: constructor that takes the year number as an int
Throw new RuntimeException(Invalid year.);
New revenue array
Assign actual days in year
New each revenue sub array for the given month
Method: isLeapYear returns true or false
Method: getDays(int m) returns the number of days in month m
1. Throw RuntimeException if month invalid
Method: getRevenue(int m, int d)
Throw RuntimeException if month invalid
Throw RuntimeException if day invalid
Return revenue for month m and day d
Method: setRevenue(int m, int d, int r)
Throw RuntimeException if month invalid
Throw RuntimeException if day invalid
Set revenue for month m and day d to r
Method: getTotal()
1. Returns the total revenue for the year
c. TestRevenue: i. Contains main()
Reads in year
Creates revenue object
Print if it is leap year
4. Set revenue for every month and day a. Use rev.monthNames.length for the number of months
5. Print revenue for every month and day as before a. Use rev.monthNames.length for the number of months
6. Print total revenue for the year by calling the getTotal method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started