struct Altman//奥特曼
{
public string name;
public int ack;
public int def;
public int hp;
public Altman(string name, int ack, int def, int hp)
{
this.name = name;
this.ack = ack;//攻击力
this.def = def;//防御力
this.hp = hp;//血量
}
public void Atk(ref Monster1 monster)//奥特曼打怪兽
{
int num = ack - monster.ack;//奥特曼的伤害量
if (num <= 0)
num = 1;
monster.hp = monster.hp-num;//怪兽剩余血量
if (monster.hp < 0)
monster.hp = 0;
Console.WriteLine("{0}攻击了{1},造成了{2}点伤害,{3}剩余血量{4}",
name, monster.name, num, monster.name, monster.hp);
}
}
struct Monster1
{
public string name;
public int ack;
public int def;
public int hp;