Last active
December 4, 2025 19:38
-
-
Save Attosius/eded57688fa7ed39132e078087aa9b0d to your computer and use it in GitHub Desktop.
ДЗ: Работа со свойствами
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace IJuniorTasks | |
| { | |
| internal class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var player = new Player(10, 20, "@"); | |
| var drawer = new Drawer(); | |
| drawer.DrawPlayer(player); | |
| Console.ReadKey(); | |
| } | |
| } | |
| public class Player | |
| { | |
| public Player(int positionX, int positionY, string symbol) | |
| { | |
| PositionX = positionX; | |
| PositionY = positionY; | |
| Symbol = symbol; | |
| } | |
| public int PositionX { get; } | |
| public int PositionY { get; } | |
| public string Symbol { get; } | |
| } | |
| public class Drawer | |
| { | |
| public void DrawPlayer(Player player) | |
| { | |
| var consolePosition = Console.GetCursorPosition(); | |
| Console.SetCursorPosition(player.PositionX, player.PositionY); | |
| Console.Write(player.Symbol); | |
| Console.SetCursorPosition(consolePosition.Left, consolePosition.Top); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment