Advertisement
Cassimus

Postac

Apr 12th, 2025
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. namespace Klasy.Podstawy;
  2.  
  3. public class Postac
  4. {
  5.     private string nazwa;
  6.     public int HP{get; private set;}
  7.     public int Atak{get; init;}
  8.  
  9. public Postac()
  10. {
  11.     System.Console.WriteLine("Stworzono postać bez cech");
  12.     nazwa="";
  13. }
  14.  
  15. public Postac(string name, int hp,int Atak)
  16.     {
  17.         nazwa = name;
  18.         HP = hp;
  19.         this.Atak = Atak;
  20.     }
  21.  
  22.     public Postac(string name )
  23.     {
  24.         nazwa = name;
  25.     }
  26.     public Postac(string name, int hp)
  27.     {
  28.          nazwa = name;
  29.          HP = hp;
  30.     }
  31.  
  32.    
  33.  
  34.     public void Wypisz()
  35.     {
  36.         System.Console.WriteLine($"{nazwa} posiada {HP} punktów życia" +
  37.             $" i  {Atak} punktow ataku");
  38.     }
  39.  
  40.     public string GetName()
  41.     {
  42.         return nazwa;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement