C # small game ------- guess number

zhaozj2021-02-08  201

Friends, just write this game, already 11 o'clock. Take a break, enjoy it. Learn any language, it is improving in the constant writing. Do not be shorter and not .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 Ready = "1234"; // Here's the value of Ready is random change. Otherwise, no one plays your game. // charr [] r = new char [] {'0', ....... '9'}; // disrupted in the order with the loop and the random function. Take the top 4 elements, give ready . Do {x = 0; y = 0; init (); for (int i = 0; i <= 3; i ) {for (int J = 0; j <= 3; J ) {ix (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 carattleness! "); Console.writeline (" ----- ----------------------- ");

}} public class mygame {public static void main () {game g = new game (); g.Play ();}} has been compiled.

转载请注明原文地址:https://www.9cbs.com/read-2534.html

New Post(0)