java 桌面应用 ui_如何将我在终端中运行的Java应用程序转变为具有UI的桌面应用程序?...

我知道他们有很多不同的方式来做到这一点,但我在与终端合作方面做得非常好,并且希望继续创建用户界面和桌面应用程序!我写了一个非常俗气而又杂乱的“数字游戏”,并且希望使它在一个带有按钮和所有爵士乐的小程序中运行!

public static void gameStart() {

System.out.println("Welcome to the Game of Awesome V1.2");

System.out.println("-------------------------------------");

spin();

}

public static void spin() {

int spinNum = (int)(10*Math.random());

Scanner input = new Scanner(System.in);

Scanner input2 = new Scanner(System.in);

System.out.println("type a number between 1 and 10:");

int guessNum = input.nextInt();

if(guessNum > 10) {

System.out.println(guessNum + " is greater than 10 you fool!");

spin();

}else if(guessNum < 1) {

System.out.println(guessNum + " is less than 1 you fool!");

spin();

}else {

System.out.println("\nSweet, looks like you chose [" + guessNum + "], good luck...");

System.out.println("\ntype \"s\" to spin and \"quit\" to, quit...");

String run = input2.nextLine();

switch (run.toLowerCase()) {

case "s":

System.out.println("\nyou spun [" + spinNum + "] and guessed [" + guessNum + "]!");

if(guessNum == spinNum) {

win();

askPlay();

}else {

lose();

askPlay();

}

break;

case "quit":

System.out.println("See ya later!");

System.out.println();

System.exit(0);

break;

default:

System.out.println("shit, you broke it! Luckily, I can fix this.");

askPlay();

System.out.println();

break;

}

}

}

public static void askPlay() {

Scanner input = new Scanner(System.in);

System.out.println("\nWanna play again? (Type \"yes\" or \"no\")");

String decideSpin = input.nextLine();

switch (decideSpin.toLowerCase()) {

case "yes":

spin();

break;

case "no":

System.out.println("\nI know it's a crappy game, thanks for playing though!");

System.out.println();

System.exit(0);

break;

default:

System.out.println("\nI'm sorry,\nI was made by a lazy "

+ "programmer and can only understand \"yes\" or \"no\"..");

askPlay();

break;

}

}

public static void win() {

System.out.println("\nWINNER: you won this insanley stupid game, of awesome! Be proud, winner. (:");

}

public static void lose() {

System.out.println("\nLOOOOOSSSSSEEEERRRR: yep, you stand with the majority with this loss.");

}我怎样才能做到这一点?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值