Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Gra
- {
- public abstract class Postac
- {
- public string Nazwa;
- public int Hp;
- public Postac(string nazwa, int hp)
- {
- this.Nazwa = nazwa;
- this.Hp = hp;
- }
- public abstract void PrzedstawSie();
- }
- public interface IBohater
- {
- void Walcz();
- }
- public class Wojownik : Postac, IBohater
- {
- public Wojownik(string nazwa, int hp) : base(nazwa, hp) { }
- public override void PrzedstawSie()
- {
- Console.WriteLine($"Witaj! Jestem {Nazwa} i mam aż {Hp} hp➕!!");
- }
- public void Walcz()
- {
- Console.WriteLine($"Roaaaaaaar!! {Nazwa} rzuca oszczepem w przeciwników! 😎");
- }
- }
- public class Program()
- {
- static void Main(string[] args)
- {
- Wojownik wojownik = new Wojownik("Ragnarok", 95);
- Postac wojownik2 = new Wojownik("Inny wojownik", 12);
- wojownik.PrzedstawSie();
- wojownik.Walcz();
- wojownik2.PrzedstawSie();
- // wojownik2.Walcz();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement