首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我不知道如何在下面的程序建立一个GUI?

我不知道如何在下面的程序建立一个GUI?
EN

Stack Overflow用户
提问于 2018-07-27 03:28:26
回答 1查看 0关注 0票数 0
代码语言:txt
复制
import java.util.Scanner;
import java.util.Random;
/* The purpose of this game is to guess the same number as the number as the 
computer comes up with.
* When you guess the right number your money is multiplied by your bet, when 
you lose you bet is take from you money.
* When your completely out of money the game ends. the point in this game is 
not to get into betting,
* this program was made for practice and fun only. Although if anyone reading 
this wants to give me money feel free (; 
*/
public class Maingame {
static int money = 100;
static int userguess;
static int computernumber;
public static void main(String[] args) {

System.out.println("Welcome to Isaac's Guessing Game Attempt number two");
System.out.println("Pick a number between 1 and 10");

playgame();
}
public static void playgame() {
Scanner in = new Scanner(System.in);
userguess = in.nextInt();
computernumber = new Random().nextInt(5) + 1;

System.out.println(" Make a bet.");
Scanner bet = new Scanner(System.in);
int Bet = bet.nextInt();
int ng = 0;

if (computernumber == userguess) {
money *= Bet;
++ng;

System.out.println("Well done You guessed the right number.");
System.out.println("Your money is now £" + money + ". Don't spend it all in         
one place.");
System.out.println("your number of guess is " + ng + ".");
System.out.println("Make a new guess.");
} else {
money -= Bet;
++ng;

System.out.println("Oh no you guessed the wrong number.");
System.out.println("You have lost £" + Bet + ". You only have £" + money + "     
left.");
System.out.println("Guess again");
}

if (money >= 0) {
playgame();
}else {
System.out.println("Your out of " +  "money. Game Over!!!!!!!!!!");
}
}}
EN

Stack Overflow用户

发布于 2018-07-27 12:43:13

我建议你寻找的是Eclipse的“WindowBuilder”工具,或者使用IDE的类似GUI设计工具。关于如何安装和使用它们,有很多教程。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档