• CustomerView


     1 public class CustomerView{
     2     private CustomerList customerList = new CustomerList(10);
     3     private static boolean loopFlag=true;
     4     private static CMUtility cm=new CMUtility();
     5     private static CustomerView cv=new CustomerView();
     6 
     7     public void enterMainMenu(){
     8         char select=cm.readMenuSelection();
     9         switch (select) {
    10             case '1':
    11                 cv.addNewCustomer();
    12                 break;
    13             case '2':
    14                 cv.modifyCustomer();
    15                 break;
    16             case '3':
    17                 cv.deleteCustomer();
    18                 break;
    19             case '4':
    20                 cv.listAllCustomers();
    21                 break;
    22             case '5':
    23                 cv.exit();
    24                 break;
    25         }
    26     }
    27         
    28     private void addNewCustomer(){
    29         Customer c=new Customer();
    30         System.out.println("---------------------添加客户---------------------");
    31         System.out.print("姓名:");
    32         c.setName(cm.readString(100));
    33 
    34         System.out.print("性别:");
    35         c.setGender(cm.readChar());
    36 
    37         System.out.print("年龄:");
    38         c.setAge(cm.readInt());
    39 
    40         System.out.print("电话:");
    41         c.setPhone(cm.readString(100));
    42 
    43         System.out.print("邮箱:");
    44         c.setEmail(cm.readString(100));
    45         customerList.addCustomer(c);
    46         System.out.println("---------------------添加完成---------------------");
    47     }
    48 
    49     private void modifyCustomer(){
    50         
    51     }
    52     
    53     private void deleteCustomer(){
    54         customerList.deleteCustomer(cm.readInt());
    55     }
    56 
    57     private void listAllCustomers(){
    58         Customer[] cu=customerList.getAllCustomers();
    59         System.out.println("---------------------客户列表---------------------");
    60         System.out.println("编号	姓名	性别	年龄	电话		邮箱");
    61         for (int i=0,counts=1;i<cu.length;i++) {
    62             if(cu[i].getName()!=null){
    63                 System.out.print(counts+"	");
    64                 System.out.print(cu[i].getName()+"	");
    65                 System.out.print(cu[i].getGender()+"	");
    66                 System.out.print(cu[i].getAge()+"	");
    67                 System.out.print(cu[i].getPhone()+"	");
    68                 System.out.println(cu[i].getEmail()+"	");
    69                 counts++;
    70             }
    71         }
    72         System.out.println("-------------------客户列表完成--------------------");
    73     }
    74     private void exit(){
    75         System.out.print("确认是否退出:");
    76         char exit=cm.readConfirmSelection();
    77         if(exit=='Y'){
    78             loopFlag=false;
    79         }
    80     }
    81 
    82     public static void main(String[] args){
    83         while(loopFlag){
    84             printMainMenu();
    85             cv.enterMainMenu();
    86         }
    87     }
    88 
    89     public static void printMainMenu(){
    90         System.out.println("
    -----------------客户信息管理软件-----------------");
    91         System.out.println("                   1 添 加 客 户");
    92         System.out.println("                   2 修 改 客 户");
    93         System.out.println("                   3 删 除 客 户");
    94         System.out.println("                   4 客 户 列 表");
    95         System.out.println("                   5 退 出
    ");
    96         System.out.print("                   请选择(1-5):");
    97     }
    98 }
  • 相关阅读:
    MySQL主从复制报错 Errno 1205
    MySQL添加索引优化SQL
    MySQL通过添加索引解决线上数据库服务器压力大问题
    手把手教你搭建MySQL双主MM+keepalived高可用架构
    SQLSERVER 维护计划无法删除
    Form表单中Post与Get方法的区别
    ASP.NET MVC中常用的ActionResult类型
    Web安全相关(五):SQL注入(SQL Injection)
    Web安全相关(四):过多发布(Over Posting)
    Web安全相关(三):开放重定向(Open Redirection)
  • 原文地址:https://www.cnblogs.com/hirasawayui/p/13128402.html
Copyright © 2020-2023  润新知