Advertisement
IvanOseledko

Homework38

Nov 12th, 2024 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Homework38
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player player1 = new Player("player1", 100, 10, 20);
  10.             Player player2 = new Player("PlAyEer2", 110, 30, 10);
  11.  
  12.             player1.ShowInfo();
  13.             Console.Write("\n");
  14.             player2.ShowInfo();
  15.         }
  16.     }
  17.  
  18.     class Player
  19.     {
  20.         private static int s_identifications = 0;
  21.  
  22.         private int _identification;
  23.         private string _nickname;
  24.         private int _health;
  25.         private int _damage;
  26.         private int _armor;
  27.  
  28.         public Player(string nickname, int health, int damage, int armor)
  29.         {
  30.             _identification = ++s_identifications;
  31.             _nickname = nickname;
  32.             _health = health;
  33.             _damage = damage;
  34.             _armor = armor;
  35.         }
  36.  
  37.         public void ShowInfo()
  38.         {
  39.             Console.WriteLine($"Идентификатор: {_identification}\nНикнейм: {_nickname}\nЗдоровье: {_health}\nУрон: {_damage}\nБроня: {_armor}");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement