public person(string n, int hp, healPotion p, takedamage d) { name = n; healthpool = hp; potion1 = p; damage1 = d; }
static void Main(string[] args) { string input; input = Console.ReadLine(); int inputparse = 10; healPotion hp1 = new healPotion(50); takedamage dmg1 = new takedamage(inputparse); person p1 = new person("fred ", 100, hp1, dmg1); Console.WriteLine("p1 name " + p1.name); Console.WriteLine("p1 health " + p1.healthpool); Console.WriteLine("potion value " + p1.potion1.health); if (input == "h") { p1.usepotion(); } else { inputparse = int.Parse(input); p1.takedmg(); } Console.WriteLine("p1 health " + p1.healthpool); Console.ReadKey(); }
public void usepotion() { potion1.use(); healthpool += potion1.use(); potion1 = null; }