Advertisement
ZhongNi

Working with Properties

Mar 19th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Classes
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Renderer renderer = new Renderer();
  10.             Player player1 = new Player(20, 10, 'P');
  11.            
  12.             renderer.Drow(player1.XPosition, player1.YPosition, player1.Symbol);
  13.         }
  14.     }
  15.  
  16.     class Renderer
  17.     {
  18.         public void Drow(int xPosition, int yPosition, char symbol)
  19.         {
  20.             Console.CursorVisible = false;
  21.             Console.SetCursorPosition(xPosition, yPosition);
  22.             Console.WriteLine(symbol);
  23.             Console.ReadKey(true);
  24.         }
  25.     }
  26.  
  27.     class Player
  28.     {
  29.         public Player(int xPosition, int yPosition, char symbol)
  30.         {
  31.             XPosition = xPosition;
  32.             YPosition = yPosition;
  33.             Symbol = symbol;
  34.         }
  35.  
  36.         public int XPosition { get; private set; }
  37.         public int YPosition { get; private set; }
  38.         public char Symbol { get; private set; }
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement