kwest87

Untitled

Feb 11th, 2023
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8.  
  9. //  Задача
  10. //
  11. //  Создать класс игрока, с полями, содержащими информацию об игроке и методом, который выводит информацию на экран.
  12. //
  13. //  В классе обязательно должен быть конструктор
  14.  
  15. namespace encapsulationSvoistva
  16. {
  17.     internal class Program
  18.     {
  19.         static void Main(string[] args)
  20.         {
  21.             Player player = new Player (20,30,"фунтик","спит");
  22.             player.DisplayInformation();
  23.         }
  24.  
  25.         class Player
  26.         {
  27.             private int _age;
  28.             private int _id;
  29.             private string _name;
  30.             private string _description;
  31.  
  32.             public Player(int age, int id, string name, string description)
  33.             {
  34.                 _age = age;
  35.                 _id = id;
  36.                 _name = name;
  37.                 _description = description;
  38.             }
  39.  
  40.             public void DisplayInformation()
  41.             {
  42.                 Console.WriteLine($"Лет : {_age}\nИдентификационный номер : {_id}\nИмя : {_name}\nПометка : {_description}");
  43.             }
  44.         }
  45.     }
  46. }
  47. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment