using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
namespace hw2
{
internal class App
{
public App()
{
Player player = new Player("홍길동", 10, 1);
Monster monster = new Monster("고블린", 10, 2);
player.Move(1, 3);
player.Attack(monster);
player.Attack(monster);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hw2
{
public class Monster
{
//멤버 변수
public string Name;
public int hp;
public int damege;
//생성자
public Monster(string name, int hp, int damege)
{
this.Name = name;
this.hp = hp;
this.damege = damege;
Console.WriteLine($"{this.Name}이 생성되었습니다.");
}
}
}
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hw2
{
public class Player
{
//멤버 변수
public string Name;
public int hp;
public int damege;
//생성자
public Player(string name, int hp, int damege)
{
this.Name = name;
this.hp = hp;
this.damege = damege;
Console.WriteLine($"{this.Name}이 생성되었습니다.");
}
public void Move(int x, int y)
{
Console.WriteLine($"{this.Name}이 {x}, {y}로 이동하였습니다.");
}
public void Attack(Monster monster)
{
Console.WriteLine($"{monster.Name}이 {this.Name}에게 피해({this.damege})을 받았습니다.");
Console.WriteLine($"남은체력 : {monster.hp - this.damege}/{monster.hp}");
monster.hp = monster.hp - this.damege;
}
}
}
using System;
namespace hw2
{
internal class Program
{
static void Main(string[] args)
{
new App();
}
}
}