Advertisement
NikaBang

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

Nov 5th, 2024 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2.  
  3. internal class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         Player player = new Player("Роман", 100, 5);
  8.  
  9.         player.ShowInfo();
  10.     }
  11.  
  12.     class Player
  13.     {
  14.         private string _name;
  15.         private int _healhs;
  16.         private int _damage;
  17.  
  18.         public Player(string name, int healhs, int damage)
  19.         {
  20.             _name = name;
  21.             _healhs = healhs;
  22.             _damage = damage;
  23.         }
  24.  
  25.         public void ShowInfo()
  26.         {
  27.             Console.WriteLine($"Имя - {_name}\nЗдоровье - {_healhs}\nУрон - {_damage}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement