Advertisement
NikaBang

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

Nov 11th, 2024 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. internal class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         Player player = new Player(10, 10, '@');
  8.         Renderer renderer = new Renderer();
  9.  
  10.         renderer.Draw(player);
  11.     }
  12.  
  13.     class Renderer
  14.     {
  15.         public void Draw(Player player)
  16.         {
  17.             Console.CursorVisible = false;
  18.             Console.SetCursorPosition(player.AxisX, player.AxisY);
  19.             Console.Write(player.Character);
  20.             Console.ReadKey(true);
  21.         }
  22.     }
  23.  
  24.     class Player
  25.     {
  26.         public Player(int axisX, int axisY, char character)
  27.         {
  28.             AxisX = axisX;
  29.             AxisY = axisY;
  30.             Character = character;
  31.         }
  32.  
  33.         public int AxisX {  get; private set; }
  34.         public int AxisY { get; private set; }
  35.         public char Character { get; private set; }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement