• 案例:我行我素购物系统 v1.1


    系统逻辑结构:

     1 import java.util.Scanner;
     2 
     3 public class ShoppingSystem {
     4  public static void main(String[] args) {
     5      String exitMsg = "谢谢使用!";
     6      System.out.println("*****************欢迎使用我行我素购物系统*********************
    ");
     7      System.out.println("提示:测试账号为【用户名:yang	密码:cheney】
    ");
     8      System.out.println("		1.登陆系统
    ");
     9      System.out.println("		2.退出系统
    ");
    10      System.out.println("************************************************************
    ");
    11      System.out.println("请选择菜单进行操作:");
    12      
    13      Scanner sc = new Scanner(System.in);
    14      int input = sc.nextInt();
    15      switch(input){
    16          case 1:
    17              LoginMenu.main(null);
    18              break;
    19          case 2:
    20              System.out.println(exitMsg);
    21              System.exit(0);//退出当前系统
    22          default:
    23              System.out.println("输入有误!") ;
    24              break;
    25      }
    26     }
    27 
    28 }

    1.登录

    /*
     * 登录菜单
     * */
    import java.util.Scanner;
    
    public class LoginMenu {
        public static void main(String[] args) {
            boolean flag = false ;
            String errorMsg = "";
            //1.接受用户名和密码
            System.out.println("请输入用户名:
    ");
            Scanner sc = new Scanner(System.in);
            String userName = sc.next();
            System.out.println("请输入密码:
    ");
            String passWord = sc.next();
            //2.判断用户名和密码
            
            if(userName.equals("yang") && passWord.equals("cheney")){
                flag = true;
            }else{
                errorMsg = "用户名或密码错误";
            }
            
            //3.用户名和密码正确进入主界面  否则给出错误提示
            
            if(flag){
                System.out.println("正在进入登录页面,请稍后。。。。");
            }else{
                System.out.println(errorMsg);
            }
        }
    
    }

    A 主菜单:

    1.客户信息管理>1.1查询客户信息 1.2 显示所有客户信息 1.3 添加客户信息 1.4 修改客户信息
    2.购物结算
    3.真情回馈
    4.注销

    B 退出

     1 /*
     2  * 登录用户主界面
     3  * */
     4 import java.util.Scanner;
     5 
     6 public class MainMenu {
     7     public static void main(String[] args) {
     8         System.out.println("*****************欢迎使用我行我素购物系统*********************
    ");
     9         System.out.println("	1.客户信息管理");
    10         System.out.println("	2.购物结算");
    11         System.out.println("	3.真情回馈");
    12         System.out.println("	4.注销");
    13         System.out.println("************************************************************
    ");
    14         
    15         Scanner sc = new Scanner(System.in);
    16         int input = sc.nextInt();
    17         
    18         switch(input){
    19         case 1:
    20             InfoManage.main(null);
    21             break;
    22         case 2:
    23             break;
    24         case 3:
    25             break;
    26         case 4:
    27             System.exit(0);
    28             break;
    29         default:
    30             System.out.println("输入错误!");
    31             break;
    32         }
    33     }
    34 
    35 }

    客户信息管理页面:

     1 /* 
     2  *客户信息管理页面 
     3  */
     4 
     5 import java.util.Scanner;
     6 
     7 public class InfoManage {
     8     public static void main(String[] args) {
     9         System.out.println("我行我素购物系统 > 主菜单 > 客户信息管理: ");
    10         System.out.println("************************************************************
    ");
    11         System.out.println("	1.查询客户信息");
    12         System.out.println("	2.显示所有客户信息");
    13         System.out.println("	3.添加客户信息");
    14         System.out.println("	4.修改客户信息");
    15         System.out.println("************************************************************
    ");
    16         System.out.println("请输入序号:");
    17 
    18         
    19         Scanner sc = new Scanner(System.in );
    20         int input = sc.nextInt();
    21         switch(input){
    22         case 1:
    23             QueInfo.main(null);
    24             break;
    25         case 2:
    26             DisAllInfo.main(null);
    27             break;
    28         case 3:
    29             AddInfo.main(null);
    30             break;
    31         case 4:
    32             ModInfo.main(null);
    33             break;
    34         default:
    35             System.out.println("输入错误!");
    36             break;
    37         }
    38         
    39     }
    40 
    41 }

    查询客户信息页面:

     1 /*
     2  * 显示当前客户信息
     3  * */
     4 import java.util.Scanner;
     5 
     6 public class QueInfo {
     7     public static void main(String[] args) {
     8         System.out.println("我行我素购物系统  > 客户信息管理 > 查询客户信息:
     ");
     9         System.out.println("请输入会员用户名:");
    10         Scanner sc = new Scanner(System.in);
    11         String input = sc.next(); 
    12         
    13         System.out.println("正在查找客户"+ input + "请稍后。。。。");
    14     }
    15 
    16 }

    显示所有客户信息:

     1 /*
     2  * 显示所有客户信息
     3  * */
     4 
     5 public class DisAllInfo {
     6     public static void main(String[] args) {
     7         System.out.println("我行我素购物系统  > 客户信息管理 > 显示所有客户客户信息:
     ");
     8         System.out.println("当前所有客户信息:
    ");
     9 
    10         System.out.println("************************************************************
    
    
    
    
    ");
    11         System.out.println("************************************************************
    ");
    12 
    13 
    14     }
    15 
    16 }

    添加客户信息:

     1 /*
     2  * 添加客户信息
     3  * */
     4 import java.util.Scanner;
     5 
     6 public class AddInfo {
     7     public static void main(String[] args) {
     8         System.out.println("我行我素购物系统  > 客户信息管理 > 添加客户信息:
     ");
     9         System.out.println("************************************************************
    ");
    10         System.out.println("请输入用户名:");
    11         Scanner sc1 = new Scanner(System.in);
    12         String UserName = sc1.next();
    13         
    14         System.out.println("请输入密码:");
    15         Scanner sc2 = new Scanner(System.in);
    16         String PWD = sc2.next();
    17         
    18         System.out.println("请输入邮箱:");
    19         Scanner sc3 = new Scanner(System.in);
    20         String Emall = sc3.next();
    21         System.out.println("你注册的信息如下:
     用户名:"+ UserName +"
    密码:"+ PWD + "
    邮箱" + Emall);
    22         System.out.println("	1.确认	2.修改");
    23         Scanner sc4 = new Scanner(System.in);
    24         int input  = sc4.nextInt();
    25         switch(input){
    26         case 1:
    27             System.out.println("注册成功!");
    28             break;
    29         case 2:
    30             ModInfo.main(null);
    31             break;
    32         default:
    33             System.out.println("输入错误!");
    34             break;
    35         }
    36 
    37 
    38 
    39         System.out.println("************************************************************
    ");
    40 
    41 
    42     }
    43 
    44 }

    修改客户信息:

     1 import java.util.Scanner;
     2 
     3 /**
     4  * 修改客户信息
     5  */
     6 
     7 public class ModInfo {
     8     public static void main(String[] args) {
     9         System.out.println("我行我素购物系统  > 客户信息管理 > 修改客户信息:
     ");
    10         System.out.println("请输入用户名:
     ");
    11         Scanner sc = new Scanner(System.in );
    12         String UserName = sc.next();
    13         System.out.println("正在查找客户"+ UserName + "请稍后。。。。");
    14     }
    15 
    16 }

    2.退出

  • 相关阅读:
    .Net控件创建热键
    .Net字符串处理
    C++ 中通过函数名字的字符串调用函数
    将.Net应用程序依赖的库文件部署到其他目录下
    VS2012生成事件
    visual studio导出项目模板
    .Net Program Unable to copy a file from objDebug to binDebug
    VBA引用.Net类库
    .Net 自定义事件
    VB.Net 解决winForm界面卡死
  • 原文地址:https://www.cnblogs.com/YangGC/p/6057376.html
Copyright © 2020-2023  润新知