Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 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 HW_5_1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Player player = new Player("William", "Russia", "vova@ya.ru");
  14.             player.WritePlayerInfo();
  15.         }
  16.     }
  17.  
  18.     class Player
  19.     {
  20.         private string _name, _country, _email;
  21.         private int _experience;
  22.  
  23.         public Player(string name, string country, string email)
  24.         {
  25.             _name = name;
  26.             _country = country;
  27.             _email = email;
  28.             _experience = 0;
  29.         }
  30.  
  31.         public Player(string name, string email)
  32.         {
  33.             _name = name;
  34.             _email = email;
  35.             _experience = 0;
  36.         }
  37.  
  38.         public string Name
  39.         {
  40.             get
  41.             {
  42.                 return _name;
  43.             }
  44.             set
  45.             {
  46.                 _name = value;
  47.             }
  48.         }
  49.  
  50.         public string Country
  51.         {
  52.             get
  53.             {
  54.                 return _country;
  55.             }
  56.             set
  57.             {
  58.                 _country = value;
  59.             }
  60.         }
  61.  
  62.         public int Experience
  63.         {
  64.             get
  65.             {
  66.                 return _experience;
  67.             }
  68.         }
  69.  
  70.         public void AddExperience(int exp)
  71.         {
  72.             _experience += exp;
  73.         }
  74.  
  75.         public void WritePlayerInfo()
  76.         {
  77.             Console.WriteLine($"Player:  {_name} \nemail: {_email}\nexperience: {_experience}");
  78.  
  79.         }
  80.  
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement