Cosmos/source2/Demos/Guess/GuessOS.cs
EdwardNutting_cp bac3f98d56 VS2013 Support
This is relatively stable but no to be considered complete. Currently supported:
1. Installing user/dev kit (as normal)
2. Creating C#/VB/F# projects (latter 2 untested)
3. Debugging a Cosmos project - see limitations list below.

Debugging limitations:
1. Breakpoints sometimes fail to be hit. Only known thing that may help is recompile everything.
2. Specific breakpoint failure case: If you try and place a breakpoint on or after a "while(true)" statement it is extremely unreliable.

Other limitations:
1. VMWare occasionally breaks. If you get "Internal error" messages, or if VS crashes (don't let Windows "fix" it) or if VMWare fails to load properly there is only one known & reliable solution: Re-run the VMWare installer and hit "Repair". No restart required. You won't lose your VMs or settings (AFAI can tell).

If it all breaks, feel free to rant at it ;)
2013-11-06 21:01:49 +00:00

44 lines
No EOL
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace GuessKernel {
public class GuessOS : Sys.Kernel {
protected int mCount = 0;
protected int mMagicNo = 22;
public GuessOS() {
// Didnt check if tickcount is working yet.. can change this later
//var xRandom = new Random(234243534);
//mMagicNo = xRandom.Next(1, 100);
}
protected override void BeforeRun() {
Cosmos.Core.HMI.Init();
Console.WriteLine("Guess Demo");
Console.WriteLine("Please guess a number from 1 to 100.");
}
protected override void Run() {
mCount++;
Console.WriteLine();
Console.WriteLine("Guess #" + mCount);
Console.Write("Please enter a guess: ");
string xInputStr = Console.ReadLine();
Console.Write("Input length: ");
Console.WriteLine(xInputStr.Length.ToString());
int xGuess = int.Parse(xInputStr);
Console.WriteLine("Your guess was " + xGuess);
if (xGuess < mMagicNo) {
Console.WriteLine("Too low.");
} else if (xGuess > mMagicNo) {
Console.WriteLine("Too high.");
} else {
Console.WriteLine("You guessed it!");
Stop();
}
}
}
}