Advertisement
IvanOseledko

Homework39

Nov 12th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Homework39
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player player = new Player('#', 10, 15);
  10.             Renderer renderer = new Renderer();
  11.  
  12.             renderer.DrawPlayer(player);
  13.         }
  14.     }
  15.  
  16.     class Player
  17.     {
  18.         public Player(char playerSymbol, int x, int y)
  19.         {
  20.             PlayerSymbol = playerSymbol;
  21.             X = x;
  22.             Y = y;
  23.         }
  24.  
  25.         public char PlayerSymbol { get; private set; }
  26.         public int X { get; private set; }
  27.         public int Y { get; private set; }
  28.     }
  29.  
  30.     class Renderer
  31.     {
  32.         public void DrawPlayer(Player player)
  33.         {
  34.             Console.CursorVisible = false;
  35.             Console.SetCursorPosition(player.X, player.Y);
  36.             Console.Write(player.PlayerSymbol);
  37.             Console.SetCursorPosition(0, 0);
  38.             Console.ReadKey();
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement