mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-06 08:12:14 +00:00
Restore guess demo.
This commit is contained in:
parent
cc3144c1ff
commit
1a538d87a0
1 changed files with 22 additions and 45 deletions
|
|
@ -29,55 +29,32 @@ namespace GuessKernel
|
||||||
|
|
||||||
private Debugger mDebugger = new Debugger("User", "Guess");
|
private Debugger mDebugger = new Debugger("User", "Guess");
|
||||||
|
|
||||||
private class KVPClass
|
|
||||||
{
|
|
||||||
public int Key;
|
|
||||||
public int Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct KVPStruct
|
|
||||||
{
|
|
||||||
public int Key;
|
|
||||||
public int Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Run()
|
protected override void Run()
|
||||||
{
|
{
|
||||||
mCount++;
|
mCount++;
|
||||||
|
mDebugger.SendMessage("Kernel", "New iteration");
|
||||||
var xListClasses = new List<KVPClass>();
|
Console.WriteLine();
|
||||||
var xListStructs = new List<KVPStruct>();
|
Console.WriteLine("Guess #" + mCount);
|
||||||
|
Console.Write("Please enter a guess: ");
|
||||||
xListClasses.Add(new KVPClass { Key = 1, Value = 2 });
|
string xInputStr = Console.ReadLine();
|
||||||
xListClasses.Add(new KVPClass { Key = 2, Value = 5 });
|
Console.Write("Input length: ");
|
||||||
|
Console.WriteLine(xInputStr.Length.ToString());
|
||||||
var xListItem= xListClasses[0];
|
int xGuess = int.Parse(xInputStr);
|
||||||
Console.Write("Classes0. Key = ");
|
Console.WriteLine("Your guess was " + xGuess);
|
||||||
Console.Write(xListItem.Key);
|
if (xGuess < mMagicNo)
|
||||||
Console.Write("Value = ");
|
{
|
||||||
Console.WriteLine(xListItem.Value);
|
Console.WriteLine("Too low.");
|
||||||
xListItem = xListClasses[1];
|
}
|
||||||
Console.Write("Classes1. Key = ");
|
else if (xGuess > mMagicNo)
|
||||||
Console.Write(xListItem.Key);
|
{
|
||||||
Console.Write("Value = ");
|
Console.WriteLine("Too high.");
|
||||||
Console.WriteLine(xListItem.Value);
|
}
|
||||||
|
else
|
||||||
xListStructs.Add(new KVPStruct { Key = 1, Value = 2 });
|
{
|
||||||
xListStructs.Add(new KVPStruct { Key = 2, Value = 5 });
|
Console.WriteLine("You guessed it!");
|
||||||
|
Stop();
|
||||||
var xStructItem = xListStructs[0];
|
}
|
||||||
Console.Write("Item0. Key = ");
|
|
||||||
Console.Write(xStructItem.Key);
|
|
||||||
Console.Write("Value = ");
|
|
||||||
Console.WriteLine(xStructItem.Value);
|
|
||||||
xStructItem = xListStructs[1];
|
|
||||||
Console.Write("Item1. Key = ");
|
|
||||||
Console.Write(xStructItem.Key);
|
|
||||||
Console.Write("Value = ");
|
|
||||||
Console.WriteLine(xStructItem.Value);
|
|
||||||
|
|
||||||
|
|
||||||
Stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue