using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class App
{
public App()
{
Zergling zergling = new Zergling("저글링", 20, 5);
Hydralisk hydralisk = new Hydralisk("히드라", 20, 5);
zergling.Att(hydralisk);
hydralisk.Hit(zergling);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class Zergling
{
public string name;
public int maxHp;
public int hp;
public int dmg;
public Zergling(string name, int maxHp, int dmg)
{
this.name = name;
this.maxHp = maxHp;
this.hp = this.maxHp;
this.dmg = dmg;
}
public void Att(Hydralisk target)
{
Console.WriteLine("{0}이 {1}를 공격({2})하였습니다.", this.name, target.name, this.dmg);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class Hydralisk
{
public string name;
public int maxHp;
public int hp;
public int dmg;
public Hydralisk(string name, int maxHp, int dmg)
{
this.name = name;
this.maxHp = maxHp;
this.hp = this.maxHp;
this.dmg = dmg;
}
public void Hit(Zergling attacker)
{
this.hp = hp - attacker.dmg;
Console.WriteLine("{0}가 {1}에게 피해-({2})를 받았습니다", this.name, attacker.name, attacker.dmg);
}
}
}