Question: BillingItem class o Must have 3 fields: 1 . An ArrayList which holds BillingSubItems, called subitems 2 . A double called amount 3 . A
BillingItem class
o Must have fields:
An ArrayList which holds BillingSubItems, called subitems
A double called amount
A string called description
o It must have constructors:
The default constructor, which initializes all fields with or an empty string,
as appropriate.
An overloaded constructor, which takes in a double to initialize amount, and
initializes description with an empty string.
An overloaded constructor, which takes in a double to initialize amount and
a string to initialize description.
All constructors should initialize subitems.It must have the following methods:
getAmount which takes in nothing and returns a double. If subitems is
empty, it returns amount. Otherwise, this method adds up the amount of all
of the BillingSubItems in subitems, returning that summation. If subitems
has elements in it do not add the BillingItems amount to the
summation.
setAmount which takes in a double and returns nothing. It updates the
value in amount with the value in the parameter. Note that no guard for the
input is necessary, as we want to allow for negative values in case we want
to offer a discount on something.
addSubItem which takes in a BillingSubItem and returns nothing, adding
it to subitems.
removeSubItem which takes in a BillingSubItem and returns nothing,
removing it from subitems.
getSubItem which takes in an integer and returns a BillingSubItem. If the
integer is in bounds of subitems, return the BillingSubItem at that position.
Otherwise, return null.
seeSubItems which takes in nothing and returns a string. This method
works exactly as seeItems in Bill, but it uses the BillingSubItems stored
inside subitems.
A getter and a setter for description.
An overload of toString If the BillingItem has no BillingSubItems, it will
simply return its description and its amount. If the BillingItem does have
BillingSubItems, it must return: Its own description, in its own line
Every BillingSubItem in the BillingItem which you can retrieve by
calling every BillingSubItems toString each in its own line
Every BillingSubItem must be preceded by a tab character t
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
