Courier
package com.feige;
public class Courier extends Preson{
private String courierId ;
public Courier(){
}
public Courier(String courierId,String pwd){
super.setPwd(pwd);
this.courierId = courierId ;
}
public Courier(String courierId,String name,String sex,int age ,String pwd){
super(name, age, pwd, sex);
this.courierId = courierId ;
}
public String getCourierId() {
return courierId;
}
public void setCourierId(String courierId) {
this.courierId = courierId;
}
@Override
public String toString() {
return "Courier{" +
"courierId='" + courierId + '\'' +
"Pwd='" + getPwd() + '\'' +
"Name='" +getName() + '\'' +
"Ssx='" + getSex() + '\'' +
"Age='" + getAge() + '\'' +
'}';
}
}
Customer
package com.feige;
public class Customer extends Preson{
private String customerId ;
private String phone ;
public Customer(){
}
public static Customer builder(){
return new Customer() ;
}
public String getCustomerId() {
return customerId;
}
public Customer setCustomerId(String customerId) {
this.customerId = customerId;
return this ;
}
public Customer Pwd(String pwd){
super.setPwd(pwd);
return this ;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
Preson
package com.feige;
public class Preson {
private String pwd ;
private String sex ;
private int age ;
private String name ;
public Preson(){
}
public Preson(String name,int age , String pwd , String sex){
this.age = age ;
this.pwd = pwd ;
this.sex = sex ;
this.name = name ;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
LonginService
package service;
import com.feige.Customer;
import java.util.Scanner;
public class LonginService {
private Scanner sc = null ;
public LonginService(Scanner scanner){
this.sc = scanner ;
}
public void register(Scanner sc){
System.out.println("请输入用户编号");
String bianhao = sc.next() ;
System.out.println("请输入用户密码");
String pwd = sc.next() ;
System.out.println("亲输入用户名");
String name = sc.next() ;
System.out.println("亲输入年龄");
int age = sc.nextInt();
System.out.println("请输入手机号");
String phone = sc.next() ;
System.out.println("请输入性别");
String sex = sc.next() ;
Customer customer = Customer.builder().setCustomerId(bianhao).Pwd(pwd);
}
}
OrderData
package tools;
import com.feige.Customer;
import java.util.Arrays;
public class OrderData {
private static int SIZE = 10;
private static int COUNT = 0;
private static Customer[] CUSTOMERDATA = new Customer[SIZE];
public static void save(Customer customer) {
if (COUNT == SIZE) {
CUSTOMERDATA = Arrays.copyOf(CUSTOMERDATA, SIZE * 2);
SIZE *= 2;
}
for (int i = 0; i < CUSTOMERDATA.length; i++) {
if (null == CUSTOMERDATA[i]) {
CUSTOMERDATA[i] = customer;
COUNT++;
return;
}
}
}
public static Customer get(String customerId, String pwd) {
for (Customer c : CUSTOMERDATA) {
if (c.getCustomerId().equals(customerId) && c.getPwd().equals(pwd)) {
return c;
}
}
return null;
}
public static Customer get(String customerId) {
for (Customer c : CUSTOMERDATA) {
if (customerId.equals(c.getCustomerId())) {
return c;
}
}return null;
}
}