Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * written by tariq scott
- */
- public class BoxManager {
- //attributes
- private Box[] boxes;
- public static final int DEF_SIZE = 100;//"the magic number"
- //constructors
- public BoxManager()//my default constructor
- {
- boxes = new Box[DEF_SIZE];
- }
- public BoxManager(int aSize)
- {
- if(aSize>0)
- {
- boxes = new Box[aSize];
- }
- }
- public void addBox(Box aBox)
- {
- for(int i = 0; i<boxes.length; i++)
- {
- if(boxes[i] == null)
- {
- boxes[i]=aBox;
- break;
- }
- }
- }
- }
- // public void sortBox()
- // {
- // boolean hasSwapped = true;
- // while(hasSwapped)
- // {
- // hasSwapped = false;
- // for(int i = 0; i<boxes.length-1; i++)
- // {
- // if(boxes[i]!=null && boxes[i+1]!=null &&
- // //(boxes[i].getVolume() > Box[i+1].getVolume()))
- // {
- // Box temp = boxes[i];
- // boxes[i] = boxes[i+1];
- // boxes[i+1] = temp;
- // hasSwapped = true;
- // }
- // }
- // }
- // }
- //
- // public void print()
- // {
- // for(int i = 0; i<boxes.length; i++)
- // {
- // if(boxes[i]!=null)
- // {
- // System.out.println(boxes[i]);
- // }
- // }
- // }
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement