Advertisement
AziLif

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

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