mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +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 class KVPClass
|
||||
{
|
||||
public int Key;
|
||||
public int Value;
|
||||
}
|
||||
|
||||
private struct KVPStruct
|
||||
{
|
||||
public int Key;
|
||||
public int Value;
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
mCount++;
|
||||
|
||||
var xListClasses = new List<KVPClass>();
|
||||
var xListStructs = new List<KVPStruct>();
|
||||
|
||||
xListClasses.Add(new KVPClass { Key = 1, Value = 2 });
|
||||
xListClasses.Add(new KVPClass { Key = 2, Value = 5 });
|
||||
|
||||
var xListItem= xListClasses[0];
|
||||
Console.Write("Classes0. Key = ");
|
||||
Console.Write(xListItem.Key);
|
||||
Console.Write("Value = ");
|
||||
Console.WriteLine(xListItem.Value);
|
||||
xListItem = xListClasses[1];
|
||||
Console.Write("Classes1. Key = ");
|
||||
Console.Write(xListItem.Key);
|
||||
Console.Write("Value = ");
|
||||
Console.WriteLine(xListItem.Value);
|
||||
|
||||
xListStructs.Add(new KVPStruct { Key = 1, Value = 2 });
|
||||
xListStructs.Add(new KVPStruct { Key = 2, Value = 5 });
|
||||
|
||||
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();
|
||||
mDebugger.SendMessage("Kernel", "New iteration");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue