Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Home_Work
- {
- class Program
- {
- static void Main(string[] args)
- {
- Player player = new Player(10, 5, '@');
- Renderer renderer = new Renderer();
- renderer.DrawPlayer(player.PositionX, player.PositionY, player.Symbol);
- Console.ReadKey();
- }
- }
- class Player
- {
- private int _positionX;
- private int _positionY;
- private char _symbol;
- public Player(int positionX, int positionY, char symbol)
- {
- SetCorrectPosition(positionX, positionY);
- _symbol = symbol;
- }
- public int PositionX => _positionX;
- public int PositionY => _positionY;
- public char Symbol => _symbol;
- private void SetCorrectPosition(int positionX, int positionY)
- {
- _positionX = GetPositiveNumber(positionX);
- _positionY = GetPositiveNumber(positionY);
- }
- private int GetPositiveNumber(int number)
- {
- if (number >= 0)
- {
- return number;
- }
- else
- {
- return 0;
- }
- }
- }
- class Renderer
- {
- public void DrawPlayer(int positionX, int positionY, char symbol)
- {
- Console.SetCursorPosition(positionX, positionY);
- Console.WriteLine(symbol);
- }
- }
- }
Add Comment
Please, Sign In to add comment