Ejemplo n.º 1
0
        public void listWeapons()
        {
            BackpackNode curr = head;

            while (curr != null)
            {
                Console.WriteLine("\nWeapon Name: \t{0}\nDamage: \t{1}\nRange:  \t{2}\nWeight: \t{3}\n", curr.weapon.name, curr.weapon.damage, curr.weapon.range, curr.weapon.weight);
                curr = curr.next;
            }
            Console.WriteLine();
        }
Ejemplo n.º 2
0
 public bool addWeapon(Weapon newWeapon)
 {
     if (head == null)
     {
         head = new BackpackNode(newWeapon);
     }
     else
     {
         BackpackNode curr = head;
         while (curr.next != null)
         {
             curr = curr.next;
         }
         curr.next = new BackpackNode(newWeapon);
     }
     presentWeight += newWeapon.weight;
     return(true);
 }
Ejemplo n.º 3
0
 public Backpack(double maxWeight)
 {
     head           = null;
     this.maxWeight = maxWeight;
     presentWeight  = 0;
 }
Ejemplo n.º 4
0
 public BackpackNode(Weapon weapon)
 {
     this.weapon = weapon;
     next        = null;
 }