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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!