RedFlys

CSharpLight HomeWork - OOP - DrawPlayer

Feb 9th, 2021 (edited)
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSharpLight_HomeWork___OOP___DrawPlayer
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Render render = new Render();
  10.             Player player = new Player(5, 4, 'X');
  11.  
  12.             player.SetSymbol('Y');
  13.             render.DrawPlayer(player.PositionX, player.PositionY, player.GetSymbol());
  14.  
  15.             Console.ReadKey();
  16.         }
  17.     }
  18.  
  19.     class Player
  20.     {        
  21.         private char _symbol;
  22.  
  23.         public int PositionX { get; private set; }
  24.         public int PositionY { get; private set; }
  25.  
  26.         public Player (int x, int y, char symbol)
  27.         {
  28.             PositionX = x;
  29.             PositionY = y;
  30.             _symbol = symbol;
  31.         }
  32.  
  33.         public char GetSymbol()
  34.         {
  35.             return _symbol;
  36.         }
  37.  
  38.         public void SetSymbol(char symbol)
  39.         {
  40.             _symbol = symbol;
  41.         }
  42.     }
  43.  
  44.     class Render
  45.     {
  46.         public void DrawPlayer(int x, int y, char symbol)
  47.         {
  48.             Console.SetCursorPosition(x, y);
  49.             Console.WriteLine(symbol);
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment