Advertisement
VodVas

Работа со свойствами

Sep 14th, 2023 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | Software | 0 0
  1. using System.Threading.Channels;
  2.  
  3. namespace Работа_с_классами
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player player = new Player(10,5,'%');
  10.             Renderer renderer = new Renderer();
  11.  
  12.             renderer.Draw(player.PositionX, player.PositionY, player.Symbol);
  13.         }
  14.     }
  15.  
  16.     class Player
  17.     {
  18.         public Player(int positionX, int positionY, char symbol)
  19.         {
  20.             PositionX = positionX;
  21.             PositionY = positionY;
  22.             Symbol = symbol;
  23.         }
  24.  
  25.         public int PositionX { get; private set; }
  26.         public int PositionY { get; private set; }
  27.         public char Symbol { get; private set; }
  28.     }
  29.  
  30.     class Renderer
  31.     {
  32.         public void Draw(int positionX, int positionY, char symbol)
  33.         {
  34.             Console.CursorVisible = false;
  35.             Console.SetCursorPosition(positionX, positionY);
  36.             Console.Write(symbol);
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement