Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- // Задача
- //
- // Создать класс игрока, с полями, содержащими информацию об игроке и методом, который выводит информацию на экран.
- //
- // В классе обязательно должен быть конструктор
- namespace encapsulationSvoistva
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Player player = new Player (20,30,"фунтик","спит");
- player.DisplayInformation();
- }
- class Player
- {
- private int _age;
- private int _id;
- private string _name;
- private string _description;
- public Player(int age, int id, string name, string description)
- {
- _age = age;
- _id = id;
- _name = name;
- _description = description;
- }
- public void DisplayInformation()
- {
- Console.WriteLine($"Лет : {_age}\nИдентификационный номер : {_id}\nИмя : {_name}\nПометка : {_description}");
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment