My friends, I just wrote this little game. It's over 11 o'clock. take a break and enjoy it. learning any language is constantly being compiled. do not use simplicity rather than simplicity. using System;
Public class Game
{
Private string number;
Private static int x, y;
Private int count = 0;
Public void init ()
{
Do {
Console. WriteLine ("Please input number :");
Number = (string) Console. ReadLine ();
} While (number. Length! = 4 );
}
Public void play ()
{
String READ = "1234 ";
// Here, the value of ready must be randomly changed. Otherwise, no one will play your game.
// Char [] r = new char [] {0,... 9 };
// Use loops and random functions to disrupt the order. Get the first four elements and give them to ready.
Do {
X = 0;
Y = 0;
Init ();
For (int I = 0; I <= 3; I ++)
{
For (int j = 0; j <= 3; j ++)
{
If (number [I] = ready [j])
{
If (I = j)
++ X;
Else
++ Y;
}
}
}
++ Count;
Console. WriteLine ("{0} A {1} B", x. ToString (), y. ToString ());
If (count> = 8)
{
Console. WriteLine ("-------------------");
Console. WriteLine ("You already lossed ");
Console. WriteLine ("-------------------");
Return;
}
} While (number! = Ready );
Console. WriteLine ("----------------------------");
Console. WriteLine ("OK! You are very cleverness! ");
Console. WriteLine ("----------------------------");
}
}
Public class MyGame
{
Public static void Main ()
{
Game g = new Game ();
G. play ();
}
}
It has been compiled.