Advertisement
voldmaks

Работа с классами

Aug 4th, 2021 (edited)
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Работа_с_классами
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Player player1 = new Player(100, 10);
  14.  
  15.             player1.ShowInfo();
  16.         }
  17.     }
  18.  
  19.     class Player
  20.     {
  21.         private int _health;
  22.         private int _armor;
  23.  
  24.         public Player(int health, int armor)
  25.         {
  26.             _health = health;
  27.             _armor = armor;
  28.         }
  29.  
  30.         public void ShowInfo()
  31.         {
  32.             Console.WriteLine($"Здоровье игрока: {_health}\nБроня игрока: {_armor}");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement