generated from admin/template
73 lines
1.6 KiB
Plaintext
73 lines
1.6 KiB
Plaintext
using System.Globalization;
|
|
|
|
class Pokemon
|
|
{
|
|
// CONSTANTS
|
|
private const byte
|
|
MIN_LEVEL = 1,
|
|
MAX_LEVEL = 100;
|
|
private const short
|
|
MIN_HP = 0,
|
|
MAX_HP = 2500;
|
|
private const string DEFAULT_NAME = "Unknown";
|
|
|
|
|
|
// FIELDS
|
|
protected string name = DEFAULT_NAME;
|
|
protected byte level = MIN_LEVEL;
|
|
protected short hp = MIN_HP;
|
|
|
|
|
|
// PROPS
|
|
public string Name
|
|
{
|
|
get => name;
|
|
set => name = value ?? DEFAULT_NAME;
|
|
}
|
|
public byte Level
|
|
{
|
|
get => level;
|
|
set
|
|
{
|
|
if (value > MAX_LEVEL) level = MAX_LEVEL;
|
|
else if(value < MIN_LEVEL) level = MIN_LEVEL;
|
|
else level = value;
|
|
}
|
|
}
|
|
public short Hp
|
|
{
|
|
get => hp;
|
|
set
|
|
{
|
|
if (value > MAX_HP) hp = MAX_HP;
|
|
else if(value < MIN_HP) hp = MIN_HP;
|
|
else hp = value;
|
|
}
|
|
}
|
|
|
|
|
|
// CONSTRUCTORS
|
|
public Pokemon(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
public Pokemon(string name, byte level) : this(name)
|
|
{
|
|
Level = level;
|
|
}
|
|
public Pokemon(string name, byte level, short hp) : this(name, level)
|
|
{
|
|
Hp = hp;
|
|
}
|
|
|
|
|
|
// METHODS
|
|
public override string ToString() => $"Pokemon: {Name}\tLevel: {Level}\tHp: {Hp}";
|
|
public virtual void Attack() => Console.WriteLine($"{Name} is attacking!");
|
|
public void ShowInfo() => Console.WriteLine($"=== INFORMATION ===\nPokemon: {Name}\t(level: {Level} | hp: {Hp})");
|
|
}
|
|
|
|
class OtherPokemon : Pokemon
|
|
{
|
|
|
|
} |