package com.charles.p1.ui;
import com.charles.p1.bean.Customer;
import com.charles.p1.service.CustomerList;
import com.charles.p1.util.CMUtility;
/**
*
* @Description CustomerView为主模块,负责菜单的显示和处理用户操作
* @author Charles
* @version
* @date 2021年10月21日下午13:26:40
*
*/
public class CustomerView {
private CustomerList customerList = new CustomerList(10);
public CustomerView(){
Customer customer = new Customer("张三",'男',23,"15979092100","[email protected]");
customerList.addCustomer(customer);
}
/**
* 显示客户信息管理软件界面的方法
*/
public void enterMainMenu() {
boolean isFlag = true;
while (isFlag) {
System.out.println("\n--------------------客户信息管理软件--------------------\n");
System.out.println(" 1 添加客户");
System.out.println(" 2 修改客户");
System.out.println(" 3 删除客户");
System.out.println(" 4 客户列表");
System.out.println(" 5 退 出\n");
System.out.print(" 请选择(1-5):");
char menu = CMUtility.readMenuSelection();
switch (menu) {
case '1':
addNewCustomer();
break;
case '2':
modifyCustomer();
break;
case '3':
deleteCustomer();
break;
case '4':
listAllCustomers();
break;
case '5':
// System.out.println("退出");
System.out.print("确认是否退出(Y/N):");
char isExit = CMUtility.readConfirmSelection();
if (isExit == 'Y') {
isFlag = false;
}
}
}
}
/**
* 添加客户的操作
*/
private void addNewCustomer() {
System.out.println("添加客户的操作");
}
/**
* 修改客户的操作
*/
private void modifyCustomer() {
System.out.println("修改客户的操作");
}
/**
* 删除客户的操作
*/
private void deleteCustomer() {
System.out.println("删除客户的操纵");
}
/**
* 显示客户列表的操作
*/
private void listAllCustomers() {
// System.out.println("显示客户列表的操作");
System.out.println("----------------------------------------客户列表----------------------------------------\n");
int total = customerList.getTotal();
if (total == 0) {
System.out.println("没有客户记录!");
} else {
System.out.println("编号\t姓名\t性别\t年龄\t电话\t\t邮箱");
Customer[] custs = customerList.getAllCustomers();
for (int i = 0; i < custs.length; i++) {
Customer cust = custs[i];
System.out.println((i + 1) + "\t" + cust.getName() +
"\t" + cust.getGender() + "\t" + cust.getAge()
+ "\t" + cust.getPhone() + "\t" + cust.getEmail());
}
}
System.out.println("--------------------------------------客户列表完成--------------------------------------");
}
public static void main(String[] args) {
CustomerView view = new CustomerView();
view.enterMainMenu();
}
}
2021.11.10,内容:CustomerView客户列表功能的实现。
猜你喜欢
转载自blog.csdn.net/change__12/article/details/121258892
今日推荐
周排行