kwest87

Untitled

Feb 15th, 2023
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3.  
  4. //Создать класс игрока, у которого есть поля с его положением в x,y.
  5. //Создать класс отрисовщик, с методом, который отрисует игрока.
  6. //
  7. //Попрактиковаться в работе со свойствами.
  8.  
  9. namespace oop2
  10. {
  11.     internal class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             char duckPlayer = '2';
  16.             Renderer renderer = new Renderer();
  17.             Player player = new Player(20, 10);
  18.             renderer.PlayerPosition(player.XPosition, player.YPosition, duckPlayer);
  19.         }
  20.  
  21.         class Player
  22.         {
  23.             public Player(int xPosition, int yPosition)
  24.             {
  25.                 XPosition = xPosition;
  26.                 YPosition = yPosition;
  27.             }
  28.  
  29.             public int XPosition { get; }
  30.             public int YPosition { get; }
  31.         }
  32.  
  33.         class Renderer
  34.         {
  35.             public void PlayerPosition(int x, int y, char duck)
  36.             {
  37.                 Console.CursorVisible = false;
  38.                 Console.SetCursorPosition(x, y);
  39.                 Console.Write(duck);
  40.             }
  41.         }
  42.     }
  43. }
  44. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment