Unity/수업내용(C#)
[3.10] 메소드 연습 2 - 반환값만 있는 메소드
ljw4104
2021. 3. 10. 17:22
using System;
namespace Study00
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(CatchCow() + "을(를) 먹었다.");
Console.WriteLine("적의 체력 : {0}", getEnemyHp());
Console.WriteLine("소유 자본 : {0}", getCapital());
Console.WriteLine("무기의 공격력 : {0}", getWeaponAttack());
Console.WriteLine("커맨드센터의 체력 : {0}", getCommandHp());
Console.WriteLine("빚 : {0}", GetBorrowedMoney());
Console.WriteLine("사람 수 : {0}", NumOfPeopleInBuilding());
Console.WriteLine("죽었나? : {0}", IsDie());
}
//소를 잡다
static private string CatchCow()
{
return "소고기";
}
//적의 체력을 가져오다.
static private int getEnemyHp()
{
int hp = 100;
return hp;
}
//소유자본을 확인하다
static private int getCapital()
{
int capital = 500000;
return capital;
}
//무기의 공격력을 확인한다.
static private int getWeaponAttack()
{
int weaponAttack = 50;
return weaponAttack;
}
//커맨드센터의 체력을 확인한다.
static private int getCommandHp()
{
int commandHp = 1500;
return commandHp;
}
//돈을 빌리다
static private int GetBorrowedMoney()
{
int dept = 80000;
return dept;
}
//건물안에 있는 사람 수를 확인한다.
static private int NumOfPeopleInBuilding()
{
int peopleInBuilding = 50;
return peopleInBuilding;
}
//죽었는지 살았는지
static private bool IsDie()
{
int hp = 0;
return hp <= 0 ? true : false;
}
//부활이 가능한가?
static private bool IsResurrectAvailable()
{
int resurrectionCount = 0;
return resurrectionCount > 0 ? true : false;
}
//지금 사용가능한 라바의 갯수를 반환
static private int UsableLarva()
{
int larvaCount = 3;
return larvaCount == 3 ? larvaCount : 0;
}
}
}