package src012;
import java.util.Scanner;
public class CustomerBiz {
String[] customers = new String[30];
// 添加客户姓名
public void addCustomer(String name) {
Scanner input = new Scanner(System.in);
boolean n = false;
do {
System.out.print("请输入客户姓名:");
for (int i = 0; i < customers.length; i++) {
if (customers[i] == null) {
customers[i] = input.next();
break;
}
}
System.out.print("要继续吗?(y/n):");
String choice = input.next();
if (!"y".equals(choice)) {
n = true;
break;
}
} while (!n);
}
// 显示客户姓名
public void showCustomer() {
System.out.println("****************************");
System.out.println("\t 客户姓名列表\t");
System.out.println("****************************");
for (int i = 0; i < customers.length; i++) {
if (customers[i] != null) {
System.out.print(customers[i] + " ");
}
}
}
// public void showCustomer() {
// Customer[] customers = new Customer[30];
// for (int i = 0; i < customers.length; i++) {
// if (customers[i] != null) {
// customers[i].show();
// }
// }
// }
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史