1、先创建Lyg类
2、分别编写方法,实现功能
3、创建TestLyi类,进行验证
import java.util.Scanner;
public class Lyg {
public void Login(){
System.out.println("\n\t\t欢迎使用经销商系统\n");
System.out.println("\t1.登陆系统\n");
System.out.println("\t2.退出\n");
System.out.println("*****************************************");
System.out.println("请选择输入数字:");
}
public void Main(){
boolean con;
System.out.println("\n\t欢迎登陆经销商系统");
System.out.println("*****************************************");
System.out.println("\t\t 1.客户信息管理\n");
System.out.println("\t\t 2.真情回馈\n");
System.out.println("*****************************************");
System.out.println("请输入数字:");
do{
con=false;
Scanner input=new Scanner(System.in);
int no=input.nextInt();
if(no==1){
Cust();
}else if (no==2){
Send();
}else if(no==0){
Login();
}else{
System.out.print("输入错误,请重新输入");
con=true;
}
}while(con);
}
public void Cust(){
System.out.println("*****************************************");
System.out.println("\t1、查询客户信息");
System.out.println("\t2、修改客户信息");
System.out.println("\t3、添加客户信息");
System.out.println("\t4、显示所有客户信息");
System.out.println("*****************************************");
System.out.println("输入数字\n0、返回上一层\n1、返回主菜单\n2、进入真情回馈");
boolean con;
do{
con=false;
Scanner input=new Scanner (System.in);
int no=input.nextInt();
if(no==0){
Main();
}else if(no==1){
Login();
}else if(no==2){
Send();
}
}while(con);
}
public void Send(){
System.out.println("*****************************************");
System.out.println("1、普卡会员抽奖");
System.out.println("2、银卡会员抽奖");
System.out.println("3、金卡会员抽奖");
System.out.println("*******************************");
System.out.println("输入要执行的抽奖活动:");
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){
Main();
}else{
System.out.println("输入错误,请重新输入数字:");
con=true;
}
} while(con);
}
}
-------------------------------
2、在创建TestLyi类
import java.util.Scanner;
public class TestLyi {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
Lyg menu=new Lyg();
menu.Login();
boolean con=true;
do{
int choice=input.nextInt();
switch(choice){
case 1:
menu.Main();
break;
case 2:
System.out.println("感谢您的使用");
con=false;
break;
}
}while(con);
}
}