Question: Requirements The features described below must be in your program. A total of four classes: the driver, Bill, BillingItem, and BillingSubItem. Bill class: o Must
Requirements
The features described below must be in your program.
A total of four classes: the driver, Bill, BillingItem, and BillingSubItem.
Bill class:
o Must have fields:
An ArrayList which holds BillingItems, called items
A static integer called nextId initialized at
An integer called id
A static double called taxPercentage initialized at
o It must only feature the default constructor, which initializes the arraylist, sets id
with the value of nextId, and then increments nextId by
o It must feature the following methods:
setTax which is static, takes in a double, and returns nothing. The double
in the parameter updates taxPercentage only if the parameter is greater
than or equal to Otherwise, this method does nothing.
A getter for taxPercentage, which is static.
addItem which takes in a BillingItem and returns nothing. It adds said
item to items.
removeItem which takes in a BillingItem and returns nothing. It removes
said item from items.
getItem which takes in an integer and returns a BillingItem. If the integer
in the parameter is within the bound of items, getItem returns the item in
that position. Otherwise, return null.
seeItems which takes in nothing and returns a string. If items is empty,
this method returns an empty string. Otherwise, it will return a list of all the
items in items in the following format:
POSITION. ITEMDESCRIPTION: $ITEMAMOUNT
eg: The bill below with items, when calling seeItems would return the
following string:
Item : $
Item : $
Item : $
calculateSubTotal which takes in nothing and returns a double. This
method adds the amount of all BillingItems stored inside of items and then
returns this summation.
calculateTotal which takes in nothing and returns a double. This method
adds the amount of all BillingItems stored inside of items and then returns
this summation multiplied by the tax percentage.
NOTE: The tax percentage is stored as a percentage eg: for
This means you will have to convert it to the appropriate
decimal number before you can use it to calculate your total. In the
example above, if taxPercentage is then you would multiply your
subtotal by to get the total.
An override of toString This override must contain the following
information:
The Bills id in its own line
Every BillingItem in the Bill which you can retrieve by calling every
BillingItems toString each in its own line
The subtotal, in its own line
The total, in its own line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
