你能帮我解决这个问题吗? [英] Can you help me solve this problem plz

查看:97
本文介绍了你能帮我解决这个问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MenuHelper class

This class is designed to provide a useful method that can be used when implementing value and type safe input checking in your programs. You will need to see the MenuHelper class API for a list of methods that should be implemented. 

You should also create a main method in this class that can be used to test out your code. You should use the method created in this class to display three menus to the user to provide a choice for a meal (you should have three options) and two sides (each should have four options) and store the user selection. Make sure to format your menu text so it looks nice. 

After the user has made each of the three selections, you should print out their responses. Note, that it is not necessary to display the name of what was chosen, merely the number that was selected. Also, you should not hardcode any part of the message to be displayed into the method. Your method should just display whatever the message parameter is. 

An example of the output (user input shown in red) might look like this: 

Please choose a main course:
 1) Chicken
 2) Beef
 3) Pork
Please enter a selection 1 – 3: 2

Please choose a side:
 1) Baked Potato
 2) Soup
 3) Salad
 4) Vegetables
Please enter a selection 1 – 4: 4

Please choose a side:
 1) Baked Potato
 2) Soup
 3) Salad
 4) Vegetables
Please enter a selection 1 – 4: 1

You selected options 2, 4, 1 for your choices.










Methods:

Identifier:	displayMenu(String message, int min, int max)
Parameters:	message – The menu text that should be displayed
min – The minimum allowable menu option
max – The maximum allowable menu option
Return Value:	int – The choice selected by the user
Other:	This method should be static.

When this method is called, it will display the String parameter which is the menu text which should include the possible selections. This method should then prompt the user to make a selection and perform value and type-safe user input checking until a user has made a valid selection. If the user does not enter an int value, they should be told "Please enter a number between $min and $max" where $min and $max are the values of the parameters min and max. 





我的尝试:



i试过但测试失败...



What I have tried:

i tried but it failed the test...

推荐答案

min和


maxwhere


min和


这篇关于你能帮我解决这个问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆