我写了一个简单的批处理文件来根据数字选择运行常用网站.这是我的代码.我试图设置它,所以如果有人输入数字6或更高,它会去,:N但每当我输入6批处理文件退出.我试过if %input% > 6 goto :N但它只是告诉我我要去谷歌.
@echo off
:Start2
cls
goto Start
:Start
title Frequently Used Websites
echo Please select a website from the list
echo with the corresponding key
echo --------------------------------------
echo [1] Google
echo [2] Wikipedia
echo [3] Facebook
echo [4] Youtube
echo [5] Yahoo
set input=
set /p input= Choice:
if %input%==1 goto Z if NOT goto Start2
if %input%==2 goto X if NOT goto Start2
if %input%==3 goto C if NOT goto …Run Code Online (Sandbox Code Playgroud) 我正在制作(我自己的版本)轮盘赌用Java,玩家可以做的一种赌注是选择要滚动的颜色.(即使是黑色,奇数是红色).有没有办法可以使用switch语句将字符串与枚举进行比较?
private enum colors{red, black};
private String colorGuess;
private boolean colorVerify = false;
public void getColorGuess(){
do{
Scanner in = new Scanner(System.in);
colorGuess = in.nextLine();
switch(colors){
case red:
colorVerify = true;
break;
case black:
colorVerify = true;
break;
default:
System.out.println("Invalid color selection!");
break;
}while(colorVerify = false);
Run Code Online (Sandbox Code Playgroud)
这就是我想要的,但它并没有让我在switch语句中使用枚举'colors'.
我正在做一个简单的抛硬币游戏,我写了几种方法来调用并使我的主要课程简短.游戏播放一次后,要求用户输入的第一个If/Else语句跳转到Else语句而不提示输入.
package cointoss;
import java.util.Random;
import java.util.Scanner;
public class Game {
int money;
int result;
int bet;
Random rn = new Random();
Scanner in = new Scanner(System.in);
String playerPick;
String aResult;
public void setMoney(int a)
{
money = a;
}
public int getMoney()
{
return money;
}
public void getBet()
{
System.out.println("How much would you like to bet?");
bet = in.nextInt();
do{
if(bet > money)
{
System.out.println("You cannot bet more than you have!");
System.out.println("You have bet " + (bet - …Run Code Online (Sandbox Code Playgroud)