Last active
November 14, 2023 07:52
-
-
Save talatari/7d240912eca0c3b3048ac645490e9b07 to your computer and use it in GitHub Desktop.
38. Task: Job With Classes
This file contains 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
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