using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace learndotnet
{
internal class Monster
{
int hp;
int maxHp = 5;
int damage = 4;
public string monster;
public Monster(string monster)
{
this.monster = monster;
hp = maxHp;
Console.WriteLine("몬스터({0})가 생성되었습니다.", monster);
}
public void HitDamage(int damage)
{
this.hp -= damage;
if (hp < 0)
{
Console.WriteLine("{0}이 사망했습니다",this.monster);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace learndotnet
{
internal class Weapon
{
public int weaponDamage = 8;
public enum eWeaponType
{
SWORD,
AXE,
BOW
}
int damage = 10;
int price = 10000;
public eWeaponType WeaponType;
public Weapon(eWeaponType WeaponType)
{
this.WeaponType = WeaponType;
Console.WriteLine("무기({0})가 생성되었습니다.",WeaponType);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace learndotnet
{
internal class App
{
public App()
{
Player player = new Player("홍길동");
Weapon weapon = new Weapon(Weapon.eWeaponType.AXE);
Monster monster = new Monster("고블린");
player.Equip(weapon);
player.Attack(monster);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace learndotnet
{
internal class Player
{
int hp;
int maxHp = 20;
public int damage = 0;
string player;
public Player(string player)
{
this.player = player;
hp = maxHp;
Console.WriteLine("플레이어({0})가 생성되었습니다.", player);
}
public void Equip(Weapon weapon)
{
this.damage = weapon.weaponDamage;
Console.WriteLine("{0}이 {1}를 착용했습니다.",this.player,weapon.WeaponType);
}
public void Attack(Monster monster)
{
Console.WriteLine("{0}이 {1}를 공격했습니다.", this.player, monster.monster);
Console.WriteLine("{0}이 ({1})의 데미지를 줬습니다.",this.player,damage);
monster.HitDamage(this.damage);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace learndotnet
{
internal class Program
{
static void Main(string[] args)
{
new App();
}
}
}