SaNik74

Working_with_properties

Jun 26th, 2024 (edited)
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. namespace Working_with_properties
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             Player davide = new Player(3, 2);
  8.             Drawer renderer = new Drawer();
  9.  
  10.             renderer.DrawUser(davide);
  11.         }
  12.     }
  13.  
  14.     class Player
  15.     {
  16.         public Player(int positionX, int positionY, char symbol = '@')
  17.         {
  18.             PositionX = positionX;
  19.             PositionY = positionY;
  20.             Symbol = symbol;    
  21.         }
  22.  
  23.         public int PositionX { get; private set; }
  24.         public int PositionY { get; private set; }
  25.         public char Symbol { get; private set; }
  26.     }
  27.  
  28.     class Drawer
  29.     {
  30.         public void DrawUser(Player user)
  31.         {
  32.             Console.SetCursorPosition(user.PositionX, user.PositionY);
  33.             Console.Write(user.Symbol);
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment