Tom 与电脑猜拳比赛
是否开始比赛?输入0-Yes 1-No
0
请输入请输入0-石头 1-剪刀 2-布
1
Tom 出的是剪刀
电脑出的是布
Tom win!
是否继续猜拳?输入0-Yes 1-No
Exceptin in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Sourse)
at java.util.Scanner.next(Unknown Sourse)
at java.util.Scanner.nextInt(Unknown Sourse)
at java.util.Scanner.nextInt(Unknown Sourse)
at com.Brady.Caiquan.main(Caiquan.java:19)
package com.Brady;
improt java.uil.Random;
improt java.uil.Scanner;
public class 猜拳{
public static void main(Strng [] args){
Tom tom = new Tom();
Scanner choose = new Scaner(System.in);
System.out.println("Tom与电脑猜拳比赛");
System.out.println("是否开始比赛?输入0-Yes 1-No");
int exam = choose.nextInt();
while(exam==0){
System.out.println("请输入0-石头 1-剪刀 2-布");
tom.input();
tom.computer();
tom.computer();
System.out.println("是否继续猜拳?输入0-Yes 1-No");
exam = choose.nextInt();
}
choose。close;
}
|
|