public class ItemizedBill extends Object
| Constructor and Description |
|---|
ItemizedBill()
Initialize this bill so that its total is zero, its list of items is
empty, and its date is the current date.
|
ItemizedBill(ItemizedBill other)
Initialize this bill by copying another bill.
|
ItemizedBill(List<Item> items)
Initialize this bill from a list of purchased items.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(Item item)
Add an item to the list of items purchased for this bill.
|
boolean |
equals(Object obj)
Compares two itemized bills for equality.
|
Date |
getDate()
Returns a copy of the date for when this bill was issued.
|
List<Item> |
getItems()
Returns the list of items purchased for this bill.
|
List<Item> |
getSortedItems()
Returns a sorted list of items purchased for this bill.
|
int |
getTotal()
Returns the total price of the bill.
|
int |
hashCode()
Returns a hash code for this bill.
|
void |
setTotal(int total)
Set the total price of the bill.
|
public ItemizedBill()
public ItemizedBill(List<Item> items)
items - a list of purchased itemspublic ItemizedBill(ItemizedBill other)
other - the bill to copypublic List<Item> getItems()
public void addItem(Item item)
item - add an item to the list of items purchased for this billpublic List<Item> getSortedItems()
public final int getTotal()
public final void setTotal(int total)
total - the total price of the billIllegalArgumentException - if the total is less than zeropublic final Date getDate()
public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
equals does not modify the list of items in this bill.