I. Guessing games:
Package COM. lovo; import Java. util. optional; public class guessgesticulate {public static void main (string [] ARGs) {Boolean goon = true; int me = 0; Using SC = new using (system. in); gesticulate Ge = new gesticulate (); do {system. out. print ("1. Stone 2. Scissors 3. Which one do you want to use? "); If (SC. hasnextint () {me = SC. nextint ();} else {system. out. print ("invalid input"); SC. nextline () ;}}while (mE <1 & me> 3); goon = Ge. contrast (me); system. out. println (GE. gethint ();} while (goon );}}
Ii. Guess digital games:
Package COM. lovo; public class gesticulate {private int systemgesticulate = 0; private string hint = ""; Public gesticulate () {This. random ();} public Boolean contrast (INT gesture) {If (gesture = systemgesticulate) {random (); If (gesture = 1) {hint = "the computer is also a stone, draw !!! ";} Else if (gesture = 2) {hint =" the computer is also scissors, draw !!! ";} Else {hint =" the computer is also a cloth, draw !!! ";}} Else if (systemgesticulate = 1) {If (gesture = 3) {hint =" the computer is a rock, you win "; return false ;} else if (gesture = 2) {hint = "computer is a rock, you lose"; return false ;}} else if (systemgesticulate = 2) {If (gesture = 3) {hint = "Computer scissors, you lost"; return false;} else if (gesture = 1) {hint = "the computer is scissors and you won"; return false ;}} else if (systemgesticulate = 3) {If (gesture = 1) {hint = "the computer is a cloth, you lose"; return false;} else if (gesture = 2) {hint = "the computer is a cloth, you win "; return false ;}} return true;} public void random () {This. systemgesticulate = (INT) (math. random () * 3 + 1);} Public String gethint () {return hint ;}}
2014.10.23 job