public Person(string n, int hp, HealPotion p, PoisonPotion PP) { name = n; healthpool = hp; potion1 = p; potion2 = PP; }
public static void Main(string[] args) { HealPotion Hp1 = new HealPotion(50); PoisonPotion Pp1 = new PoisonPotion(5); Person p1 = new Person("Fred", 1, Hp1, Pp1); Console.WriteLine("P1 name: " + p1.name); Console.WriteLine("P1 health: " + p1.healthpool); Console.WriteLine("P1 potion value: " + p1.potion1.health); Console.WriteLine("P1 potion value: " + p1.potion2.health); p1.usepotion2(); Console.WriteLine("p1 health: " + p1.healthpool); Console.ReadKey(); }
public void usepotion() { healthpool += potion1.use(); potion1 = null; }