import java.util.Scanner;
public class QuessMachine01 {
int num;
String name;
int money;
int choice;
public void initial(){
num = (int)(Math.random()*10/3+1);
switch (num) {
case 1:
dian();
break;
case 2:
zxc();
break;
case 3:
dianshuihu();
break;
String name;
int money;
int choice;
public void initial(){
num = (int)(Math.random()*10/3+1);
switch (num) {
case 1:
dian();
break;
case 2:
zxc();
break;
case 3:
dianshuihu();
break;
}
}
public void dian(){
name = "电动自行车" ;
money = 1000;
}
public void zxc(){
name = "自行车" ;
money = 500;
}
public void dianshuihu(){
name = "电水壶" ;
money = 200;
}
public void guess(){
Scanner in = new Scanner (System.in);
for (int i = 0; i < 4; i++) {
if (i!=0) {
System.out.println("在猜一次吧!");
choice = in.nextInt();
}
if (i<3) {
if (money==choice) {
System.out.println("恭喜你,猜对了");
break;
}else if (money>choice){
System.out.println("在小点");
}else {
System.out.println("在大点");
}
}
if (i==3) {
System.out.println("4次内没有猜对,下次努力吧!");
}
}
}
public static void main(String[] args) {
QuessMachine01 q = new QuessMachine01 ();
Scanner in = new Scanner (System.in);
q.initial();
System.out.println("请猜测"+q.name+"的价格");
q.choice = in.nextInt();
q.guess();
}
}
QuessMachine01 q = new QuessMachine01 ();
Scanner in = new Scanner (System.in);
q.initial();
System.out.println("请猜测"+q.name+"的价格");
q.choice = in.nextInt();
q.guess();
}
}