2014.10.23 job

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.