|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectfoodManagement.SortedListOfImmutables
public class SortedListOfImmutables
A SortedListOfImmutables represents a sorted collection of immutable objects that implement the Listable interface. An array of references to Listable objects is used internally to represent the list. The items in the list are always kept in alphabetical order based on the names of the items. When a new item is added into the list, it is inserted into the correct position so that the list stays ordered alphabetically by name.
Constructor Summary | |
---|---|
SortedListOfImmutables()
This constructor creates an empty list by creating an internal array of size 0. |
|
SortedListOfImmutables(SortedListOfImmutables other)
Copy constructor. |
Method Summary | |
---|---|
void |
add(Listable itemToAdd)
Adds an item to the list. |
void |
add(SortedListOfImmutables listToAdd)
Adds an entire list of items to the current list, maintaining the alphabetical ordering of the list by the names of the items. |
boolean |
checkAvailability(Listable itemToFind)
Checks to see if a particular item is in the list. |
boolean |
checkAvailability(SortedListOfImmutables listToCheck)
Checks if a list of items is contained in the current list. |
Listable |
get(int i)
Returns a reference to the item in the ith position in the list. |
int |
getRetailValue()
Returns the sum of the retail values of all items in the list. |
int |
getSize()
Returns the number of items in the list. |
int |
getWholesaleCost()
Returns the sum of the wholesale costs of all items in the list. |
void |
remove(Listable itemToRemove)
Removes an item from the list. |
void |
remove(SortedListOfImmutables listToRemove)
Removes an entire list of items from the current list. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SortedListOfImmutables()
public SortedListOfImmutables(SortedListOfImmutables other)
other
- the list that is to be copiedMethod Detail |
---|
public int getSize()
public Listable get(int i)
i
- index of item requested
public void add(Listable itemToAdd)
itemToAdd
- refers to a Listable item to be added to this listpublic void add(SortedListOfImmutables listToAdd)
listToAdd
- a list of items that are to be added to the current objectpublic void remove(Listable itemToRemove)
itemToRemove
- refers to the item that is to be removed from the listpublic void remove(SortedListOfImmutables listToRemove)
listToRemove
- list of items that are to be removed from this listpublic int getWholesaleCost()
public int getRetailValue()
public boolean checkAvailability(Listable itemToFind)
itemToFind
- item to look for
public boolean checkAvailability(SortedListOfImmutables listToCheck)
listToCheck
- list of items that may or may not be a subset of the
current list
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |