public bool addWeapon(Weapon w) { if (maxWeight < (presentWeight + w.weight)) { return(false); } BPnode nn = new BPnode(w); presentWeight += nn.w.weight; if (head == null) { head = nn; return(true); } BPnode current = head; while (current.next != null) { current = current.next; } current.next = nn; return(true); }
public void printBackpack() { Console.Write("Backpack: "); BPnode current = head; while (current != null) { Console.Write("{0}, ", current.w.weaponName); current = current.next; } Console.WriteLine(); }
public Backpack() { maxWeight = 30; presentWeight = 0; head = null; }
public BPnode(Weapon weap) { w = weap; next = null; }