从一个开关里走出来,但没有布尔值,这有可能吗?(Going out from a switch inside a do while, but without a boolean, it's possible? Java)
所以这个代码是关于在一个do中给出一个输入的限制。 在这种情况下,你有3个机会继续。 在那之后停止,也有oportunitie停止只是提示任何键加入,而且当你开始时,你是否有oportunitie(这里进入开关)退出程序。 问题或我卡住的地方在这里。
也许这可能没有布尔值,或者可能改变或添加我还不知道的东西。 对不起,我试图找到一个答案,但我看到它是关于走出一个while循环whith布尔左右。 不是这样的。
Scanner kb = new Scanner(System.in); // c = continue char c; // attempt to limit the input to 3 times int attempt = 3; // option = op int op = 0; do { do{ System.out.println("Choose continue[0] or go out[1]."); while (!kb.hasNextInt()) { kb.nextLine(); System.out.println("It's not a number."); } op = kb.nextInt(); } while ( op <= -1 || op >= 2 ); switch (op) { case 0: System.out.println("Continue!"); break; case 1: //here I tried; attempt = -1 break; //is where I think it needs to be something default: break; } System.out.println("Do you wanna try again,"+attempt+" less?[c]+enter\n" + "Any other key + enter to exit."); c = kb.next(".").toUpperCase().charAt(0); attempt--; } while ( attempt > 0 && ( c == 'C' ) ); //here also to put !( op == 0 ) kb.close();
So the code is about giving a limit of inputs in a do while. In this case you have 3 oportunities to continue. After that the do while stops, also you have the oportunitie to stop just presing any key plus enter, but also when you start, do you have the oportunitie (here enters the switch) to exit the program. The problem or where I get stuck is here.
That maybe it's possible without a boolean, or maybe changing or adding something that I don't yet know. Sorry I try to find an answer but all I saw it's about going out a while loop whith boolean or so. Not like this.
Scanner kb = new Scanner(System.in); // c = continue char c; // attempt to limit the input to 3 times int attempt = 3; // option = op int op = 0; do { do{ System.out.println("Choose continue[0] or go out[1]."); while (!kb.hasNextInt()) { kb.nextLine(); System.out.println("It's not a number."); } op = kb.nextInt(); } while ( op <= -1 || op >= 2 ); switch (op) { case 0: System.out.println("Continue!"); break; case 1: //here I tried; attempt = -1 break; //is where I think it needs to be something default: break; } System.out.println("Do you wanna try again,"+attempt+" less?[c]+enter\n" + "Any other key + enter to exit."); c = kb.next(".").toUpperCase().charAt(0); attempt--; } while ( attempt > 0 && ( c == 'C' ) ); //here also to put !( op == 0 ) kb.close();
原文:https://stackoverflow.com/questions/47147451
其他回答
需要连接国外的服务器
嗯
我用的网一vpn注册和登录facebook的,你可以去试试。
相关问答
更多-
Facebook 怎么注册不了账号[2022-10-11]
不要共享或者代创建账户,非常不安全。在国内需要连接到国际网络,才能连接到Facebook、谷歌等海外公司的服务器。但以前的V*N通信技术因为现在的新规定,服务器都已经关闭或者IP被屏蔽,并且运营商大批量检测都已经切断了连接,不能再使用,HOSTS更是早就不能再使用了。 而且即使可以连接到谷歌应用商店等模块,谷歌学术和Facebook为了防止机器人采集滥用,很多多人登录滥用过的IP地址都会屏蔽,显示拒绝访问,关闭风险账户等。目前可以连接到国际网络并可以使用的有2BSS等这些。 因为创建账户后的日常使用也是需要 ... -
注册facebook网络错误[2023-11-27]
FaceBook因为其服务商不愿意遵守中国的法律,所以不获准许在中国范围内开展业务。需要把本地IP改成外地的IP地址以后。这样就需要一个代理软件了。免费的代理都不稳定的。推荐你使用远足加速器。代理IP之后,详细注册步骤如下: 手机步骤: 第一步:搜悦游下载加速器 第二步:免费注册账号 第三步:连接大陆以外的节点 第四步:打开浏览器输入你要浏览的网址 手机设置vpn的方法 设置-网络或者通用-虚拟网络(vpn) 类型:pptp 描述:vpn 填上账号密码和IP连接 电脑的步骤: 1.搜索facebook,进入 ... -
gitlab注册时弹出以下语句无法注册成功 编辑[2022-05-07]
gitlab.com注册时需要输入验证码,就是reCAPTCHA,类似于12306的验证码。但是这个验证码是Google提供的,所以你懂的,需要翻*Q才能看得到验证码!! -
Facebook注册在最后一步总是不成功,但没说出错原因怎么办呢[2022-08-13]
好像是不是需要,翻&* 墙,,软件 -
手机注册facebook账号步骤[2022-03-28]
关于苹果手机注册方法要先打开手机设置,在点开通用、点开之后连接巧玲vpn,连接vpn之后就可以注册fk了 连接成功后就可以注册了 参考巧玲vpn -
facebook为什么注册不了?[2021-12-11]
facebook是全球最大的社交网站,由于一些其他原因,在中国大陆无法正常使用,在大陆以外的地区可正常注册使用。为遵守国家相关法令规定,本文只介绍facebook如何进行注册,对如何在中国大陆使用不作介绍 打开浏览器,在地址栏输入“www.facebook.com”,进入facebook的主页,在登录框下面点击“注册facebook”按钮 在弹出的页面中填写一些必要的注册信息,如姓名、邮箱、生日、密码等信息。这里一定要填写正确的邮箱地址,要接收验证邮件,全部填写完成后再点击下面的“注册”按钮 登录注册时填写 ... -
为何facebook总是无法注册成功?[2023-03-27]
搜索 3gipv6 vpn 手机电脑都可以用 官网有手机的设置教程 电脑直接下载个客户端登录 连接成功后就可以注册和访问 Google facebook 推特 YTB等网站 -
为什么不能注册facebook[2022-04-07]
安卓手机设置VPN方法 一、打开“设置”,找到“更多网络” 二、在更多网络列表中点击 VPN 选项,选择创建一个新的 VPN 连接 三、选择PPTP类型,接着输入 VPN 的名称,优度vpn,和 VPN 的服务器地址,用户名及密码,记得将PPP加密选项关掉 四、保存,接着连接。(连接成功后,可以在百度查询手机IP) 连接之后就可以上Instagram,Facebook,Google等国外网站了 -
没有公开的方式来获取这些信息。 抱歉。 There's no public way to get this information. Sorry.
-
PHP Facebook注册(PHP Facebook Registration)[2023-05-16]
使用Facebook FacePilation插件时有很多选择。 使用该插件,我希望能满足您的所有需求。 http://developers.facebook.com/docs/reference/plugins/facepile/ There are so many options when you go with Facebook FacePilation plugin. Use that plugin, we will be getting all of your needs i hope. http ...