Advertisement
TravaMan

Basic_Task22

Dec 29th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Basic_Task22
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player player = new Player("Первый", 5, 2);
  10.  
  11.             Drawer.DrawPlayer(player);
  12.         }
  13.     }
  14.  
  15.     class Player
  16.     {
  17.         public string Name { get; set; }
  18.         private int _x;
  19.  
  20.         public int X
  21.         {
  22.             get
  23.             {
  24.                 return _x;
  25.             }
  26.  
  27.             set
  28.             {
  29.                 if (value > 0)
  30.                 {
  31.                     _x = value;
  32.                 } else
  33.                 {
  34.                     _x = 0;
  35.                 }
  36.             }
  37.         }
  38.  
  39.         private int _y;
  40.  
  41.         public int Y
  42.         {
  43.             get
  44.             {
  45.                 return _y;
  46.             }
  47.  
  48.             set
  49.             {
  50.                 if (value > 0)
  51.                 {
  52.                     _y = value;
  53.                 }
  54.                 else
  55.                 {
  56.                     _y = 0;
  57.                 }
  58.             }
  59.         }
  60.  
  61.         public Player(string name, int x, int y)
  62.         {
  63.             Name = name;
  64.             X = x;
  65.             Y = y;
  66.         }
  67.     }
  68.  
  69.     class Drawer
  70.     {
  71.         public static void DrawPlayer(Player player, char symbol = '@')
  72.         {
  73.             Console.SetCursorPosition(player.X, player.Y);
  74.             Console.Write(symbol);
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement