티스토리 뷰

개발일기/수업!

180822 수업 코드~

노럭맨 2018. 8. 22. 13:48
class Test
{
public Test()
{
Console.WriteLine("20180822-2 코드 결과값입니다.");
// 여기 아래서부터 연습하세요!
string monName = "좀비123";
float monMaxHp = 500;
float monHp = monMaxHp;
float monAtk = 15.5f;
string heroName = "홍길동";
float heroMaxHp = 350;
float heroHp = heroMaxHp;
float heroAtk = 11.3f;
int potionSValue = 10;
int potionMValue = 50;
int mithrilArmorValue = 500;
Console.WriteLine("몬스터의 이름은 "+monName+"입니다.");
Console.WriteLine("몬스터의 최대체력은 "+monMaxHp+"입니다.");
Console.WriteLine("몬스터의 체력은 "+monHp+"입니다.");
Console.WriteLine("몬스터의 공격력은 "+monAtk+"입니다.");
Console.WriteLine("영웅의 이름은 "+heroName+"입니다.");
Console.WriteLine("영웅의 최대체력은 "+heroMaxHp+"입니다.");
Console.WriteLine("영웅의 체력은 "+heroHp+"입니다.");
Console.WriteLine("영웅의 공격력은 "+heroAtk+"입니다.");
Console.WriteLine("체력물약(소)는 체력을 "+potionSValue+" 올려줍니다.");
Console.WriteLine("체력물약(중)은 체력을 " + potionMValue + " 올려줍니다.");
Console.WriteLine("미스릴방어구는 최대체력을" + mithrilArmorValue + " 올려줍니다.");
Console.WriteLine("몬스터의 체력이 0이 되면 사망합니다.");
Console.WriteLine("몬스터가 공격했습니다!");
heroHp -= monAtk;
Console.WriteLine("영웅이 "+monAtk+"만큼 피해를 입었습니다. ["+heroHp+"/"+heroMaxHp+", " +(heroHp/heroMaxHp).ToString("#0%")+"]");
Console.WriteLine("영웅이 몬스터를 공격했습니다.");
monHp -= heroAtk;
Console.WriteLine("몬스터가 "+heroAtk+"만큼 피해를 입었습니다. [" + monHp + "/" + monMaxHp + ", " + (monHp / monMaxHp).ToString("#0%") + "]");
heroHp += potionSValue;
Console.WriteLine("영웅이 물약(소)를 사용했습니다. [" + heroHp + "/" + heroMaxHp + ", " + (heroHp / heroMaxHp).ToString("#0%") + "]");
Console.WriteLine("몬스터가 공격했습니다!");
heroHp -= monAtk;
Console.WriteLine("영웅이 " + monAtk + "만큼 피해를 입었습니다. [" + heroHp + "/" + heroMaxHp + ", " + (heroHp / heroMaxHp).ToString("#0%") + "]");
heroMaxHp += mithrilArmorValue;
Console.WriteLine("영웅이 미스릴 방어구를 착용했습니다. [" + heroHp + "/" + heroMaxHp + ", " + (heroHp / heroMaxHp).ToString("#0%") + "]");
heroHp += potionMValue;
Console.WriteLine("영웅이 물약(중)을 사용했습니다. [" + heroHp + "/" + heroMaxHp + ", " + (heroHp / heroMaxHp).ToString("#0%") + "]");
bool isBothDie = monHp <= 0 && heroHp <= 0;
Console.WriteLine("영웅도 죽고 몬스터도 죽었습니까? ["+isBothDie+"]");
bool isOneAlive = monHp > 0 || heroHp > 0;
Console.WriteLine("영웅이 살거나 몬스터가 살았습니까? ["+isOneAlive+"]");
Console.Read();
}
}


 

'개발일기 > 수업!' 카테고리의 다른 글

180822-2 코드!  (0) 2018.08.22
c#에서의 물음표 연산자에 대하여...  (0) 2018.08.22
180822-1 코드~  (0) 2018.08.22
180821 수업! 코드! ㅎㅎ  (0) 2018.08.21
댓글
최근에 올라온 글
Total
Today
Yesterday
TAG
more
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31