Skip to content

Instantly share code, notes, and snippets.

@talatari
Last active November 14, 2023 07:52
Show Gist options
  • Save talatari/ea779f6509e9f92d1a01ca75d260eab2 to your computer and use it in GitHub Desktop.
Save talatari/ea779f6509e9f92d1a01ca75d260eab2 to your computer and use it in GitHub Desktop.
39. Task: Working With Properties
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