Advertisement
bonumopus

class4

May 12th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 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 playerClass
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Player player1 = new Player();
  14.             Player player2 = new Player(125, 2, 500);
  15.             Console.WriteLine("Игрок 1:");
  16.             player1.ShowStats();
  17.             Console.WriteLine("\nИгрок 2:");
  18.             player2.ShowStats();
  19.         }
  20.     }
  21.  
  22.     class Player
  23.     {
  24.         private int _health;
  25.         private int _level;
  26.         private int _experience;
  27.  
  28.         public Player(int health, int level, int experience)
  29.         {
  30.             _health = health;
  31.             _level = level;
  32.             _experience = experience;
  33.         }
  34.  
  35.         public Player()
  36.         {
  37.             _health = 100;
  38.             _level = 1;
  39.             _experience = 0;
  40.         }
  41.  
  42.         public void ShowStats()
  43.         {
  44.             Console.WriteLine("Здоровье - " + _health + "\nУровень - " + _level + "\nОпыт - " + _experience);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement