首页 > 其他 > 详细

CustomerView

时间:2020-06-15 00:01:26      阅读:43      评论:0      收藏:0      [点我收藏+]
 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("编号\t姓名\t性别\t年龄\t电话\t\t邮箱");
61         for (int i=0,counts=1;i<cu.length;i++) {
62             if(cu[i].getName()!=null){
63                 System.out.print(counts+"\t");
64                 System.out.print(cu[i].getName()+"\t");
65                 System.out.print(cu[i].getGender()+"\t");
66                 System.out.print(cu[i].getAge()+"\t");
67                 System.out.print(cu[i].getPhone()+"\t");
68                 System.out.println(cu[i].getEmail()+"\t");
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("\n-----------------客户信息管理软件-----------------");
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 退 出\n");
96         System.out.print("                   请选择(1-5):");
97     }
98 }

 

CustomerView

原文:https://www.cnblogs.com/hirasawayui/p/13128402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!