Last active
November 14, 2023 07:52
-
-
Save talatari/ea779f6509e9f92d1a01ca75d260eab2 to your computer and use it in GitHub Desktop.
39. Task: Working With Properties
This file contains 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
public class Program | |
{ | |
static void Main() | |
{ | |
Player player = new Player(10, 10); | |
Painter painter = new Painter(); | |
painter.DrawPosition(player); | |
} | |
} | |
public class Player | |
{ | |
public Player(int positionX, int positionY) | |
{ | |
PositionX = positionX; | |
PositionY = positionY; | |
} | |
public int PositionX { get; private set; } | |
public int PositionY { get; private set; } | |
} | |
public class Painter | |
{ | |
public void DrawPosition(Player player) | |
{ | |
Console.WriteLine($"Игрок находится в координате по горизонтали: " + | |
$"{player.PositionX}\n" + | |
$"Игрок находится в координате по вертикали: " + | |
$"{player.PositionY}\n"); | |
Console.SetCursorPosition(player.PositionY, player.PositionX); | |
Console.Write('@'); | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment