-
Notifications
You must be signed in to change notification settings - Fork 103
/
SnubsCodeEp005.cs
62 lines (52 loc) · 1.97 KB
/
SnubsCodeEp005.cs
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
62
using System;
namespace TWiT.Tv.Coding101.Snubs.Example.Ep5
{
internal class Coding101SnubsExampleEp5
{
private static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("What is your favorite color? (Choose RED! Or, BLUE!): ");
string text = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write("\nWhat is the air speed velocity of an unladen swallow? (It may be 3): ");
string repeatNumberText = Console.ReadLine();
int repeatNumber = 0;
if (!int.TryParse(repeatNumberText, out repeatNumber))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Your text, {0}, is not a number", repeatNumberText);
Console.ResetColor();
Console.WriteLine("Type <Enter> to Exit");
Console.Read();
return;
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("\nPrint on seperate lines? (y/n): ");
string onSeperateLinesText = Console.ReadLine();
bool onSeperateLines = false;
if (onSeperateLinesText == "y")
{
onSeperateLines = true;
}
int count = 1;
for (; count <= repeatNumber; count++)
{
if (onSeperateLines)
{
Console.WriteLine(text);
}
else
{
Console.Write("{0} ", text);
}
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nThe Count was {0}.", count);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nType <Enter> to Exit.");
Console.ResetColor();
Console.ReadKey();
}
}
}