namespace ReplaceNestedConditionalWithGuardClauses
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(PersonIsfligible(16, true, true, true));
Console.WriteLine(PersonIsfligible(18, true, true, true));
Console.WriteLine(PersonIsfligible(16, true, true, false));
Console.WriteLine(PersonIsfligible(16, true, false, true));
}
//Some sort of contest entry requirements!
public static bool PersonIsfligible(int age, bool canadianCitizen, bool acceptedConditionOfEntry, bool IsfulltimeStudent)
{
//Gurad Cludeses : 아래 condion의 문장의 부정으로 조건 문을 만들고 return false
if (age < 18) return false;
if (!canadianCitizen) return false;
if (!acceptedConditionOfEntry) return false;
if (!IsfulltimeStudent) return false;
return true;
////nested conditions
//if (age > 18)
//{
// if (canadianCitizen)
// {
// if (IsfulltimeStudent)
// {
// //if statement can go on
// return true;
// }
// }
//}
//return false;
}
}
}