C#/수업 과제
레벨업 과제 ( 메서드 )
Bueong_E
2023. 1. 3. 23:04
반응형
SMALL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study01
{
class App
{
float nextExp = 115f;
float myExp = 89.5f;
int maxLevel = 2;
int level = 1;
public App()
{
Console.WriteLine("App");
GetExp(19f);
GetExp(33.14f);
GetExp(33.14f);
}
float GetExp(float exp)
{
if(level < maxLevel)
{
Console.WriteLine("경험치(19)를 획득 했습니다", exp);
myExp = exp + myExp;
if (myExp < 115f)
{
float currentExp = (myExp / nextExp) * 100;
Console.WriteLine("경험치 : ({0:0.00}/{1}) {2:0}%", myExp, nextExp, currentExp);
}
else if (myExp >= 115f)
{
myExp = exp + myExp;
float currentExp = 100f;
myExp = 115;
Console.WriteLine("경험치 : ({0:0}/{1}) {2:0}%", myExp, nextExp, currentExp);
Console.WriteLine("레벨업을 했습니다.");
Console.WriteLine("{0}레벨이 되었습니다.", maxLevel);
++level;
}
}
else if(level == maxLevel)
{
Console.WriteLine("최대 레벨에 도달 했습니다. ");
}
return myExp;
}
//경험치(19)를 획득 했습니다. (108.50/115) 94%
//경험치(33.14)를 획득 했습니다. (115/115) 100%
//레벨업을 했습니다.
//2레벨이 되었습니다.
//최대 레벨에 도달 했습니다.
}
}
반응형
LIST