首页 新闻 会员 周边

程序运行错误

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-01-22 21:12

package changeGoshoopingMenu;
import java.util.Scanner;
public class Menu {
/*登陆菜单*/
public void showLoginMenu(){
System.out.println("\n\t欢迎使用我行我素购物管理系统\t");
System.out.println("\t\t1.登 录 系 统\n");
System.out.println("\t\t2.退 出\n");
System.out.println("******************************");
System.out.println("请选择,输入数字:");
}
/*主菜单*/
public void showMainMenu(){
boolean con;
do{
con=false;
/*输入数字选择菜单*/
Scanner input=new Scanner(System.in);
int no=input.nextInt();
if(no==1){
showCustMenu();
}else if(no==2){
showLoginMenu();
}else if(no==0){
showLoginMenu();
}else{
System.out.println("输入错误,请重新输入数字:");
con=true;
}
}while(con);
}
/*真情回馈*/
public void showSendMenu(){
boolean con;
do {
con=false;
/*输入数字选择菜单*/
Scanner input =new Scanner(System.in);
int no=input.nextInt();
if(no==1){
System.out.println("执行幸运大放送");
}else if(no==2){
System.out.println("执行幸运抽奖");
}else if(no==3){
System.out.println("执行生日问候");
}else if(no==0){
showMainMenu(); //返回主菜单
}else{
System.out.println("输入错误,请重新输入数字:");
con=true;
}
}while(con);
}
/*客户信息管理*/
public void showCustMenu(){
boolean con;
do {
con=false;
/*输入数字选择菜单*/
Scanner input =new Scanner(System.in);
int no=input.nextInt();
if(no==1){
System.out.println("查询客户信息");
}else if(no==2){
System.out.println("添加客户信息");
}else if(no==3){
System.out.println("执行生日问候");
}else if(no==4){
System.out.println("显示所有客户信息");
}else if(no==0){
showMainMenu(); //返回主菜单
}else{
System.out.println("输入错误,请重新输入数字:");
con=true;
}
}while(con);
}
}

 

package changeGoshoopingMenu;

import java.util.*;

public class TestMenu{
boolean con=true;
do{/*显示主菜单*/
Menu menu=new Menu();
menu.showLoginMenu();
/*实现菜单*/
Scanner input=new Scanner(System.in);
int choice=input.nextInt();
switch(choice){
case 1:
menu.showMainMenu();
break;
case 2:
System.out.println("谢谢您的使用!");
con=false;
break;
}
}while(con);
}

追逐,小天的主页 追逐,小天 | 初学一级 | 园豆:197
提问于:2013-01-22 21:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册