1. 옳게 입력할 때까지 반복하기
2. 입력한 프레임 수 만큼 반복하기
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
//4. while - 애니메이션 실행1
//범위 내로 입력한 프레임 수 만큼 애니메이션 실행하기
int currentFrame =0;
Console.Write("실행할 애니메이션의 이름을 적으세요. ");
string aniName=Console.ReadLine();
//범위에 맞게 입력할때까지 반복하기
while (true)
{
Console.Write("애니메이션의 total 프레임은 몇 프레임 입니까(6~30)? ");
currentFrame = Convert.ToInt32(Console.ReadLine());
//범위가 틀리면 반복 (6보다 작고 30보다 크면 false)
if(currentFrame<6 || currentFrame>30)
{
Console.WriteLine("범위를 벗어났습니다!");
}
//범위가 맞으면 반복문 나오기
else
{
break;
}
}
//Play라고 제대로 입력할 때까지 반복하기
for(; ; )
{
Console.Write("애니메이션을 실행하시려면 'Play'라고 입력 하세요 ");
string playOrder = Console.ReadLine();
//제대로 입력하지 않았으면 다시 반복문으로 제어를 넘김
if(playOrder!="Play")
{
Console.WriteLine("다시 제대로 입력하세요");
continue;
}
//아니면 반복문 종료
else
{
break;
}
}
//입력받은 frame 수만큼 실행하기
int aniCurrentCount = 0;
while(aniCurrentCount< currentFrame)
{
aniCurrentCount++;
Console.WriteLine("{0} {1} 프레임 실행", aniName, aniCurrentCount);
}
Console.WriteLine("애니메이션을 종료합니다.");
|
'C# > 수업내용' 카테고리의 다른 글
2020.04.07. 수업내용 - while 문 5 (애니메이션 3) (0) | 2020.04.07 |
---|---|
2020.04.07. 수업내용 - while 문 4 (애니메이션 2) (0) | 2020.04.07 |
2020.04.07. 수업내용 - while 문 2 (구구단) (0) | 2020.04.07 |
2020.04.07. 수업내용 - while 문 1 (줄넘기) (0) | 2020.04.07 |
2020.04.07. 수업내용 - 소수점 자리 나타내기, 크리티컬 데미지(for, if) (0) | 2020.04.07 |