Question: Help me with is in Java A total of four classes: the driver, Bill, BillingItem, and BillingSubItem. Bill class: o Must have 4 fields: 1

Help me with is in Java
A total of four classes: the driver, Bill, BillingItem, and BillingSubItem.
Bill class:
o Must have 4 fields:
1. An ArrayList which holds BillingItems, called items
2. A static integer called nextId, initialized at 0
3. An integer called id
4. A static double called taxPercentage, initialized at 0
o It must only feature the default constructor, which initializes the arraylist, sets id with the value of nextId, and then increments nextId by 1.
o It must feature the following methods:
1. 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 0. Otherwise, this method does nothing.
2. A getter for taxPercentage, which is static.
3. addItem(), which takes in a BillingItem and returns nothing. It adds said item to items.
4. removeItem(), which takes in a BillingItem and returns nothing. It removes said item from items.
5. 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.
6. 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. ITEM-DESCRIPTION: $ITEM-AMOUNT
e.g.: The bill below with 3 items, when calling seeItems(), would return the following string:
0. Item 1: $100.00
1. Item 4: $30.00
2. Item 5: $120.00
7. 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.
8. 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 (e.g.: 10 for
10%). 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 10, then you would multiply your
subtotal by 1.1 to get the total.
9. 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
BillingItem class
o Must have 3 fields:
1. An ArrayList which holds BillingSubItems, called subitems
2. A double called amount
3. A string called description
o It must have 3 constructors:
1. The default constructor, which initializes all fields with 0 or an empty string, as appropriate.
2. An overloaded constructor, which takes in a double to initialize amount, and
initializes description with an empty string.
3. An overloaded constructor, which takes in a double to initialize amount and
a string to initialize description.
4. All constructors should initialize subitems.
o It must have the following methods:
1. 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.
2. 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.
3. addSubItem(), which takes in a BillingSubItem and returns nothing, adding
it to subitems.
4. removeSubItem(), which takes in a BillingSubItem and returns nothing,
removing it from subitems.
5. 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.
6. 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.
7. A getter and a setter for description.
8. 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).
e.g.: There are 2 Billing Items below. The first one has no
BillingSubItems, while the second one has 2.
Item 1: $100.00
Item 4
SubItem 1: $10.00
SubItem 2: $20.00
BillingSubItem class:
o
Help me with is in Java A total of four classes:

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 Programming Questions!