public void PrintList() { Console.WriteLine("List: "); NodeBackpack curr = head; while (curr != null) { Console.WriteLine("{0}-{1}-{2}", curr.data.weaponName, curr.data.cost, curr.data.damage); curr = curr.next; } }
public void AddLast(Weapon sWeapon) { //create a new node NodeBackpack newNode = new NodeBackpack(sWeapon); //head is null if (head == null) { head = newNode; return; } NodeBackpack curr = head; while (curr.next != null) // find the last item { curr = curr.next; } curr.next = newNode; }
public Backpack(double maxWeight, double presentWeight) { this.maxWeight = maxWeight; this.presentWeight = presentWeight; head = null; }
public NodeBackpack(Weapon data) { this.data = data; next = null; }