Last active
June 9, 2025 15:52
-
-
Save Strelok78/8447eb64635ec830f1b36fa7d2cf21eb to your computer and use it in GitHub Desktop.
class and constructor practice
This file contains hidden or 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
| using System; | |
| using System.IO; | |
| namespace iJuniorPractice | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Player player = new Player(1, 1, '@'); | |
| Drawer drawer = new Drawer(); | |
| drawer.DrawPlayer(player); | |
| } | |
| } | |
| class Player | |
| { | |
| public Player(int xPosition, int yPosition, char symbol) | |
| { | |
| XAxis = xPosition; | |
| YAxis = yPosition; | |
| Symbol = symbol; | |
| } | |
| public int XAxis { get; } | |
| public int YAxis { get; } | |
| public char Symbol { get; } | |
| } | |
| class Drawer | |
| { | |
| public void DrawPlayer(Player player) | |
| { | |
| Console.SetCursorPosition(player.XAxis, player.YAxis); | |
| Console.Write(player.Symbol); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment