public class ItemOrder
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private int |
arraySize |
private int |
currentSize |
private Furniture[] |
orderList |
Constructor and Description |
---|
ItemOrder()
Creates an empty item order of
arraySize items. |
Modifier and Type | Method and Description |
---|---|
void |
add(Furniture f,
int index,
boolean force)
Adds an item furniture to the
orderList at the given index. |
void |
del(int index)
Deletes (nulls) a furniture object in
orderList where the given index is. |
void |
deleteAll()
Deletes (nulls) everything in the list.
|
Furniture |
get(int index)
Gets the furniture object of the given index in the
orderList if valid. |
int |
getCurrentSize()
Current array size.
|
int |
getFirstAvailable()
Gets the index of the first available space within
orderList . |
int |
getFreeSpace()
Gets the number of free spaces within the
orderList . |
int |
getMaxSize() |
double |
getPrice()
Gets the price of all the items within
orderList . |
boolean |
isValidIndex(int i)
Checks if the given number is a valid index (0 to
arraySize ). |
void |
normalise()
Shifts all objects within
orderList so that there are no gaps in between items in the array. |
private final transient int arraySize
private int currentSize
private Furniture[] orderList
ItemOrder()
arraySize
items.public int getFirstAvailable()
orderList
. (-1 if full).public Furniture get(int index)
orderList
if valid. (Else, returns null).index
- Index of the item within the array.public void add(Furniture f, int index, boolean force)
orderList
at the given index.f
- Furniture object to add.index
- Index within the orderList
array.force
- If a furniture object already exists there, passing this as true will overwrite it. If this is false, will just skip.public void del(int index)
orderList
where the given index is. Then shifts everything in the array into order again.index
- Index of item in the list that gets deleted.public void deleteAll()
public int getMaxSize()
public int getCurrentSize()
arraySize
).public int getFreeSpace()
orderList
.public double getPrice()
orderList
.public boolean isValidIndex(int i)
arraySize
).i
- Index to check if it's valid.public void normalise()
orderList
so that there are no gaps in between items in the array.