Advertisement
Vlad_Savitskiy

Class Player

Apr 19th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLight
  4. {
  5.     class Player
  6.     {
  7.         public string Name { get; }
  8.         public int Health { get; }
  9.         public int Money { get; set; }
  10.  
  11.         public Player(string name, int health, int money)
  12.         {
  13.             Name = name;
  14.             Health = health;
  15.             Money = money;
  16.         }
  17.  
  18.         public void ShowInfo()
  19.         {
  20.             Console.WriteLine($"Статистика игрока {Name}:\n   Жизней - {Health}\n   Денег - {Money} ");
  21.         }
  22.     }
  23.  
  24.     class Program
  25.     {
  26.         static void Main()
  27.         {
  28.             Player player1 = new Player("Вася", 150, 0);
  29.             Player player2 = new Player("Олег", 120, 120);
  30.  
  31.             player1.ShowInfo();
  32.             player2.ShowInfo();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement