W1thr

ООП-1

Mar 6th, 2021 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 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 Homework1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Player player = new Player(50, 18, 25);
  14.             player.ShowInfo();
  15.         }
  16.     }
  17.  
  18.     class Player
  19.     {
  20.         private int _health;
  21.         private int _armor;
  22.         private int _damage;
  23.         private string _name;
  24.  
  25.         public Player(int health, int armor, int damage, string name = "Default Player")
  26.         {
  27.             _health = health;
  28.             _armor = armor;
  29.             _damage = damage;
  30.             _name = name;
  31.         }
  32.  
  33.         public void ShowInfo()
  34.         {
  35.             Console.WriteLine("Здоровье - " + _health +
  36.                 "\nБроня - " + _armor +
  37.                 "\nУрон - " + _damage +
  38.                 "\nИмя - " + _name);
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment