I made two classes for my "Backpack". You may ignore these if you wish.
/** * A storage space for items * * @author Erik * @version 1 */ public class Canteen { private double maxVolume; private int percentFull; public Canteen() { percentFull=0; maxVolume=2; } public Canteen(double maxVolume, int percentFull) { this.percentFull=percentFull; this.maxVolume=maxVolume; if(percentFull>100){ percentFull=100;} } public void fill() { percentFull=100; } public void empty() { percentFull=0; } public boolean sip() { boolean onesip=true; if(percentFull<1){ onesip=false; }else{ percentFull-=1;} return onesip; } public boolean sip(int numberOfSips) { boolean enoughwater=true; if(numberOfSips>percentFull){ enoughwater=false; }else{ percentFull-=numberOfSips;} return enoughwater; } public double getMaxVolume() { return maxVolume; } public double getPercentFull() { return percentFull; } }
And THIS is the class I'm having trouble with:
/** * Storage for Equipment. * * @author Erik * @version 1 */ public class Backpack { private Canteen theCanteen; private Equipment[] theEquipment; Backpack() { this.theCanteen=null; this.theEquipment=new Equipment[0]; } public void addCanteen(String Canteen) { } }
In the addCanteen method, I want to add the Canteen into the backpack that is currently empty, but I'm not sure how I'd get around to doing that. Any ideas?