public class Box extends java.lang.Object implements java.lang.Iterable<Ball>
| Constructor and Description | 
|---|
Box(double maxVolume)
Constructor that creates a new box. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
add(Ball b)
Adds a Ball to this box. 
 | 
void | 
clear()
Empties the box, i.e. 
 | 
boolean | 
contains(Ball b)
This method returns true if this box contains the specified Ball. 
 | 
java.util.Iterator<Ball> | 
getBallsFromSmallest()
This method returns an iterator that yields all the balls in this box in order of ascending
 size, i.e., the smallest Ball first, followed by Balls of increasing size. 
 | 
double | 
getVolume()
Each Ball has a volume. 
 | 
java.util.Iterator<Ball> | 
iterator()
Implements the Iterable interface for this box. 
 | 
boolean | 
remove(Ball b)
Removes a ball from the box. 
 | 
int | 
size()
Returns the number of Balls in this box. 
 | 
public Box(double maxVolume)
maxVolume - total volume of balls that this box can containpublic java.util.Iterator<Ball> iterator()
iterator in interface java.lang.Iterable<Ball>public boolean add(Ball b)
b - the Ball to be addedpublic java.util.Iterator<Ball> getBallsFromSmallest()
public boolean remove(Ball b)
b - the Ball to be removedpublic double getVolume()
public int size()
public void clear()
public boolean contains(Ball b)
b - the Ball to be checked for membership in this box