world
Class Sack

java.lang.Object
  |
  +--world.Sack

public class Sack
extends Object

Class that implements a container for packages.

Version:
$Revision: 1.1 $
Author:
Allen D. Ball

Constructor Summary
Sack()
          Creates a sack.
 
Method Summary
 void empty()
          Method to clear all packages (empty) from the sack.
 int getCount()
          Method to get the sack's package count.
 Pkg[] getPkgs()
          Method to get the sack's packages.
 TableModel getTableModel()
          Returns a table model for displaying the sack.
 int getWeight()
          Method to get the sack's total weight.
 Pkg put(Pkg pkg)
          Method to add a package to the sack.
 Pkg remove(int id)
          Method to remove a package from a the sack.
 Pkg remove(Pkg pkg)
          Method to remove a package from a the sack.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sack

public Sack()
Creates a sack.
Method Detail

getCount

public int getCount()
Method to get the sack's package count.
Returns:
The sack's package count.

getWeight

public int getWeight()
Method to get the sack's total weight.
Returns:
The sack's weight.

getPkgs

public Pkg[] getPkgs()
Method to get the sack's packages.
Returns:
The sack's weight.

put

public Pkg put(Pkg pkg)
Method to add a package to the sack.
Parameters:
pkg - The package to add to the sack.

remove

public Pkg remove(int id)
Method to remove a package from a the sack.
Parameters:
id - The package ID of the package to remove from the sack.
Returns:
The package that was removed or null if the package was not found.

remove

public Pkg remove(Pkg pkg)
Method to remove a package from a the sack.
Parameters:
pkg - The package to remove from the sack.
Returns:
The package that was removed or null if the package was not found.

empty

public void empty()
Method to clear all packages (empty) from the sack.

getTableModel

public TableModel getTableModel()
Returns a table model for displaying the sack.


Copyright 2002 Allen D. Ball. All rights reserved.