Cosmos/source/Cosmos.Shell.Guess/Program.cs
kudzu_cp 2f2deccfbd
2008-09-16 01:34:13 +00:00

47 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.Build.Windows;
namespace Cosmos.Demo.Guess {
public class Program {
#region Build Console
// This contains code to launch the build console. Most users should not chagne this.
[STAThread]
public static void Main() {
BuildUI.Run();
}
#endregion
public static void Init() {
var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
Cosmos.Kernel.Debug.TraceOn();
Random xRandom = new Random((int)(Cosmos.Hardware.Global.TickCount
+ Cosmos.Hardware.RTC.GetSeconds()));
// Divide by 100, get remainder
int xMagicNo = xRandom.Next() % 100;
Console.WriteLine("I am thinking of a number between 0 and 100. What is it?");
Cosmos.Kernel.Debug.TraceOff();
while (true) {
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Take a guess: ");
Console.ForegroundColor = ConsoleColor.White;
short xGuess = short.Parse(Console.ReadLine());
if (xGuess == xMagicNo) {
break;
}
Console.ForegroundColor = ConsoleColor.Red;
if (xGuess > xMagicNo) {
Console.WriteLine("Too high.");
} else {
Console.WriteLine("Too low.");
}
}
Console.WriteLine("You got it!!!!");
}
}
}