2019.12.21 客户管理系统

/**
* Customer.java
* com.guoyun
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月21日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.guoyun;
/**
* ClassName:Customer
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月21日 上午11:19:52
*
* @see
*/
public class Customer {
private String name;
private char gender;
private int age;
private String phone;
private String email;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}

}

 ************************************************************************************************

/**
* CustomerList.java
* com.guoyun
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月21日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.guoyun;
/**
* ClassName:CustomerList
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月21日 上午11:19:43
*
* @see
*/
public class CustomerList {
public static Customer[] list=new Customer[10];

}

  ************************************************************************************************

/**
* CustomerView.java
* com.guoyun
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月21日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.guoyun;

import java.util.Scanner;

/**
* ClassName:CustomerView
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月21日 上午11:19:08
*
* @see
*/
public class CustomerView {
public static Scanner scanner=new Scanner(System.in);
public static void main(String[] args) {
menu();


}
public static void menu() {
boolean flag=true;
while(flag) {
System.out.println("--------------客户信息管理软件---------------");
System.out.println(" 1.添加客户 ");
System.out.println(" 2.修改客户 ");
System.out.println(" 3.删除客户 ");
System.out.println(" 4.客户列表 ");
System.out.println(" 5.退出软件 ");
System.out.println("请选择(1~5)");
String choice=scanner.nextLine();
switch (choice) {
case "1":
addCustomer();
break;
case "2":
showCustomer();
updateCustomer();
break;
case "3":
showCustomer();
deleteCustomer();
break;
case "4":
showCustomer();
break;
case "5":
flag=false;
System.out.println("欢迎下次使用!");
break;

default:
System.out.println("无效命令,请重新输入!");
break;
}
}
}
public static void addCustomer() {
System.out.println("--------------添加客户---------------");
boolean flag=true;
for (int i = 0; i < CustomerList.list.length; i++) {
if (CustomerList.list[i]==null) {
Customer customer = new Customer();
System.out.println("请输入客户的姓名");
String name=scanner.nextLine();
customer.setName(name);
System.out.println("请输入客户的性别");
String gender=scanner.nextLine();
customer.setGender(gender.toCharArray()[0]);
System.out.println("请输入客户的年龄:");
String age=scanner.nextLine();
customer.setAge(Integer.parseInt(age));
System.out.println("请输入客户的电话:");
String phone=scanner.nextLine();
customer.setPhone(phone);
System.out.println("请输入客户的邮箱:");
String email=scanner.nextLine();
customer.setEmail(email);
CustomerList.list[i]=customer;
System.out.println("--------------添加客户完成---------------");
flag=false;
break;


}
}
if (flag) {
System.out.println("列表已满!");
}
}
public static void updateCustomer() {
System.out.println("--------------删除客户---------------");
System.out.println("请选择待修改客户的编号:");
String num=scanner.nextLine();
boolean flag=true;
for (int i = 0; i < CustomerList.list.length; i++) {
if (CustomerList.list[i]!=null) {
if ((i+1)==Integer.parseInt(num)) {
flag=false;
System.out.println("请选择要修改的选项:1姓名 2性别 3年龄 4电话5 邮箱");
String choice=scanner.nextLine();
switch (choice) {
case "1":
System.out.println("请输入修改后的姓名:");
String newName=scanner.nextLine();
CustomerList.list[i].setName(newName);
System.out.println("修改成功!");
break;
case "2":
System.out.println("请输入修改后的性别:");
String newGender=scanner.nextLine();
CustomerList.list[i].setGender(newGender.toCharArray()[0]);;
System.out.println("修改成功!");
break;
case "3":
System.out.println("请输入修改后的年龄:");
String newAge=scanner.nextLine();
CustomerList.list[i].setAge(Integer.parseInt(newAge));;
System.out.println("修改成功!");
break;
case "4":
System.out.println("请输入修改后的电话:");
String newPhone=scanner.nextLine();
CustomerList.list[i].setPhone(newPhone);;
System.out.println("修改成功!");
break;

case "5":
System.out.println("请输入修改后的邮箱:");
String newEmail=scanner.nextLine();
CustomerList.list[i].setEmail(newEmail);;
System.out.println("修改成功!");
break;

default:
break;
}

}
}
}
if (flag) {
System.out.println("没有找到该编号的客户");
}
}
public static void deleteCustomer() {
System.out.println("--------------删除客户---------------");
System.out.println("请选择待删除客户的编号:");
String num=scanner.nextLine();
boolean flag=true;
for (int i = 0; i < CustomerList.list.length; i++) {
if (CustomerList.list[i]!=null) {
if ((i+1)==Integer.parseInt(num)) {
flag=false;
// System.out.println("请选择要修改的选项:1姓名 2性别 3年龄 4电话5 邮箱");
// String choice=scanner.nextLine();
// switch (choice) {
// case "1":
// System.out.println("请输入修改后的姓名:");
// String newName=scanner.nextLine();
// CustomerList.list[i].setName(newName);
// System.out.println("修改成功!");
// break;
// case "2":
// System.out.println("请输入修改后的性别:");
// String newGender=scanner.nextLine();
// CustomerList.list[i].setGender(newGender.toCharArray()[0]);;
// System.out.println("修改成功!");
// break;
// case "3":
// System.out.println("请输入修改后的年龄:");
// String newAge=scanner.nextLine();
// CustomerList.list[i].setAge(Integer.parseInt(newAge));;
// System.out.println("修改成功!");
// break;
// case "4":
// System.out.println("请输入修改后的电话:");
// String newPhone=scanner.nextLine();
// CustomerList.list[i].setPhone(newPhone);;
// System.out.println("修改成功!");
// break;
//
// case "5":
// System.out.println("请输入修改后的邮箱:");
// String newEmail=scanner.nextLine();
// CustomerList.list[i].setEmail(newEmail);;
// System.out.println("修改成功!");
// break;
//
// default:
// break;
// }
CustomerList.list[i]=null;
System.out.println("--------------删除完成---------------");
}
}
}
if (flag) {
System.out.println("没有找到该编号的客户");
}
}
public static void showCustomer() {
System.out.println("--------------客户列表---------------");
System.out.println("编号\t\t姓名\t\t性别\t\t年龄\t\t电话\t\t\t\t邮箱");
for (int i = 0; i < CustomerList.list.length; i++) {
if (CustomerList.list[i]!=null) {
System.out.println((i+1)+"\t\t"+
CustomerList.list[i].getName()+"\t\t"+
CustomerList.list[i].getGender()+"\t\t"+
CustomerList.list[i].getAge()+"\t\t"+
CustomerList.list[i].getPhone()+"\t\t\t\t"+
CustomerList.list[i].getEmail());
}

}
System.out.println("--------------客户列表完成---------------");
}
}

猜你喜欢

转载自www.cnblogs.com/aojie/p/12076653.html
今日推荐