c#/수업 내용
질롯 vs 저글링
by 이지훈26
2021. 8. 26.
using System;
class Program
{
static void Main(string[] args)
{
Zelot zelot = new Zelot();
Zugling zugling = new Zugling();
//또 공격하고 싶다
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
zelot.Attack(zugling);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Zelot
{
private int damage = 8;
private int hp = 100;
private int shild = 60;
public Zelot()
{
Console.WriteLine("질롯이 생성되었습니다.");
}
public void Attack(Zugling zugling)
{
if (zugling.hp <= 0)
{
Console.WriteLine("대상이 없습니다.");
}
else
{
Console.WriteLine("질롯이 {0}을 공격합니다.", zugling);
zugling.Hit(damage);
}
}
private void Hit()
{
}
private void Die()
{
}
}
using System;
class Zugling
{
private int damage = 5;
private int hp = 35;
//생성자
public Zugling()
{
Console.WriteLine("저글링이 생성되었습니다.");
}
//공격하다
private void Attack()
{
}
public void Hit(int zelotdamage)
{
Console.WriteLine("{0}만큼 피해를 받았습니다.", zelotdamage);
//체력 감소(나의 체력을 감소 시키세요)
hp = hp - zelotdamage;
Console.WriteLine("hp: {0}", hp);
//hp가 0이거나 0보다 작다면 Die메서드를 호출 시키세요
if (hp <= 0)
{
Die();
}
}
//죽다
private void Die()
{
Console.WriteLine("죽었습니다.");
}
}