Last active
May 17, 2023 07:42
-
-
Save Strelok78/098ea423858f35f387d12ef26bc8cbf9 to your computer and use it in GitHub Desktop.
Player class, with fields containing information about the player and a method that displays the information on the screen.
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
internal class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine("Enter Players' name"); | |
string name = Console.ReadLine(); | |
Console.WriteLine("Enter Players' age"); | |
int age = int.Parse(Console.ReadLine()); | |
Player player = new Player(age, name); | |
player.ShowDetails(); | |
} | |
} | |
class Player | |
{ | |
private int _age; | |
private string _name; | |
public Player(int age, string name) | |
{ | |
_age = age; | |
_name = name; | |
} | |
public void ShowDetails() | |
{ | |
Console.WriteLine($"Players name: {_name}\nPlayers age: {_age}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment