|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
ObjectOrder
public class Order
An order.
CS 537, Spring 2007, Project 3.
A mapping from Grain types to integers (number of bushels).
| Field Summary | |
|---|---|
private Map<Grain,Integer> |
amt
The actual mapping. |
private static int |
VERSION
Source version number. |
| Constructor Summary | |
|---|---|
Order()
Creates a new Order with all amounts zero. |
|
| Method Summary | |
|---|---|
void |
change(Grain g,
int diff)
Changes the mount of "g" by "diff". |
void |
change(Order incr)
Changes the amount of each grain g by incr.get(g). |
Order |
copy()
Returns a copy of this Order. |
int |
get(Grain g)
Gets the amount of "g" in this order. |
void |
set(Grain g,
int n)
Sets the amount of "g" to "n". |
void |
set(int n)
Sets the amounts of all grains to "n". |
String |
toString()
Returns a readable version of this order. |
int |
total()
Returns the total amount of grain in this order. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final int VERSION
private Map<Grain,Integer> amt
| Constructor Detail |
|---|
public Order()
| Method Detail |
|---|
public String toString()
toString in class Objectpublic int get(Grain g)
g - the grain
public void set(Grain g,
int n)
g - a grainn - the amount of grain gpublic void set(int n)
n - the amount to set.public int total()
public void change(Grain g,
int diff)
g - a graindiff - the change in the amount of grain gpublic void change(Order incr)
incr - the amount to increment by.public Order copy()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||