コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public Backpack(double maxWeight, double presentWeight)
 {
     this.maxWeight     = maxWeight;
     this.presentWeight = presentWeight;
     head = null;
 }
コード例 #4
0
 public NodeBackpack(Weapon data)
 {
     this.data = data;
     next      = null;
 }