Advertisement
Dr_Max_Experience

Task 2

Feb 17th, 2022 (edited)
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ООП
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Renderer renderer = new Renderer();
  10.  
  11.             Player player1 = new Player(3, 4);
  12.             Player player2 = new Player(5, 2, '&');
  13.  
  14.             renderer.DrawPlayer(player1.PositionX, player1.PositionY, player1.Symbol);
  15.             renderer.DrawPlayer(player2.PositionX, player2.PositionY, player2.Symbol);
  16.         }
  17.     }
  18.  
  19.     class Player
  20.     {
  21.         public int PositionX { get; private set; }
  22.         public int PositionY { get; private set; }
  23.         public char Symbol { get; private set; }
  24.  
  25.         public Player(int positionX, int positionY, char symbol = '@')
  26.         {
  27.             PositionX = positionX;
  28.             PositionY = positionY;
  29.             Symbol = symbol;
  30.         }
  31.     }
  32.  
  33.     class Renderer
  34.     {
  35.         private int _defauldCursorPositionX = 10;
  36.         private int _defauldCursorPositionY = 10;
  37.  
  38.         public void DrawPlayer(int positionX, int positionY, char symbol)
  39.         {
  40.             Console.SetCursorPosition(positionX, positionY);
  41.             Console.Write(symbol);
  42.             Console.SetCursorPosition(_defauldCursorPositionX, _defauldCursorPositionY);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement