Advertisement
TravaMan

Basic_Task21

Dec 29th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Basic_Task21
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player player1 = new Player(1, "Первый Первович", 20);
  10.             Player player2 = new Player(2, "Второй Второвович", 25);
  11.             Player player3 = new Player(3, "Третий Третививич", 30);
  12.  
  13.             player1.ShowInfo();
  14.             player2.ShowInfo();
  15.             player3.ShowInfo();
  16.         }
  17.     }
  18.  
  19.     class Player
  20.     {
  21.         private int _id;
  22.         private string _name;
  23.         private int _age;
  24.  
  25.         public Player(int id, string name, int age)
  26.         {
  27.             _id = id;
  28.             _name = name;
  29.             _age = age;
  30.         }
  31.  
  32.         public void ShowInfo()
  33.         {
  34.             Console.WriteLine($"{_id}. {_name} ({_age})");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement