illiden

Players

Dec 10th, 2019
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 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 Player
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Player[] players = { new Player("Player 1", 100, 100, 40),
  14.                                 new Player("Player 2", 150, 50, 70),
  15.                                 new Player("Player 3", 50, 200, 20)};
  16.             for (int i = 0; i < players.Length; i++)
  17.             {
  18.                 players[i].ShowInfo();
  19.                 Console.WriteLine();
  20.             }
  21.             Console.ReadKey();
  22.         }
  23.     }
  24.  
  25.     class Player
  26.     {
  27.         private string _nickname;
  28.         private int _health;
  29.         private int _mana;
  30.         private int _armor;
  31.  
  32.         public Player(string name, int health, int mana,  int armor)
  33.         {
  34.             _nickname = name;
  35.             _health = health;
  36.             _mana = mana;
  37.             _armor = armor;
  38.         }
  39.  
  40.         public void ShowInfo()
  41.         {
  42.             Console.WriteLine("Ник: " + _nickname);
  43.             Console.WriteLine("HP: " + _health);
  44.             Console.WriteLine("MP: " + _mana);
  45.             Console.WriteLine("Броня: " + _armor);
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment