Skip to content

Instantly share code, notes, and snippets.

@talatari
Last active November 14, 2023 07:52
Show Gist options
  • Save talatari/7d240912eca0c3b3048ac645490e9b07 to your computer and use it in GitHub Desktop.
Save talatari/7d240912eca0c3b3048ac645490e9b07 to your computer and use it in GitHub Desktop.
38. Task: Job With Classes
public class Program
{
static void Main()
{
Player player = new Player(nickName: "MightyBlow",
hitPoints: 100,
damage: 20,
armor: 33);
player.ShowStats();
}
}
public class Player
{
private string _nickname;
private int _hitPoints;
private int _damage;
private int _armor;
public Player(string nickName, int hitPoints, int damage, int armor)
{
_nickname = nickName;
_hitPoints = hitPoints;
_damage = damage;
_armor = armor;
}
public void ShowStats()
{
Console.WriteLine($"Nickname: {_nickname} \n\n" +
$"HitPoints: {_hitPoints} \n" +
$"Damage: {_damage} \n" +
$"Armor: {_armor}");
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment