솔루션을 검토하여 재사용 가능한 메서드 만들기

완료됨

다음 코드는 앞 단원의 과제에 대한 가능한 한 가지 솔루션입니다.

Random random = new Random();
int luck = random.Next(100);

string[] text = {"You have much to", "Today is a day to", "Whatever work you do", "This is an ideal time to"};
string[] good = {"look forward to.", "try new things!", "is likely to succeed.", "accomplish your dreams!"};
string[] bad = {"fear.", "avoid major decisions.", "may have unexpected outcomes.", "re-evaluate your life."};
string[] neutral = {"appreciate.", "enjoy time with friends.", "should align with your values.", "get in tune with nature."};

TellFortune();

void TellFortune() 
{
    Console.WriteLine("A fortune teller whispers the following words:");
    string[] fortune = (luck > 75 ? good : (luck < 25 ? bad : neutral));
    for (int i = 0; i < 4; i++) 
    {
        Console.Write($"{text[i]} {fortune[i]} ");
    }
}

이 코드는 다른 지점에 줄 바꿈을 추가했거나 코드의 서식을 다르게 지정했을 수 있기 때문에 "가능한 솔루션 중 하나"일 뿐입니다.

사소한 코드 차이에 관계없이 코드를 실행할 때 다음 출력 메시지 중 한 가지가 표시됩니다.

```Output A
A fortune teller whispers the following words:
You have much to look forward to. Today is a day to try new things! Whatever work you do is likely to succeed. This is an ideal time to accomplish your dreams! 
```

```Output B
A fortune teller whispers the following words:
You have much to appreciate. Today is a day to enjoy time with friends. Whatever work you do should align with your values. This is an ideal time to get in tune with nature. 
```

```Output C
A fortune teller whispers the following words:
You have much to fear. Today is a day to avoid major decisions. Whatever work you do may have unexpected outcomes. This is an ideal time to re-evaluate your life.
```

출력은 luck 변수의 값에 따라 달라져야 합니다.

과제를 완료했으면 축하합니다! 다음 단원의 지식 점검을 계속 진행하세요.

중요

이 과제를 완료하는 데 문제가 있는 경우 계속 진행하기 전에 이전 단원을 복습하는 것이 좋습니다. 다른 모듈에서 설명하는 새로운 내용을 모두 이해하려면 이 모듈의 내용을 숙지하고 있어야 합니다.