FeiGe快遞系統(tǒng)----登錄模塊
第一部分創(chuàng)建Customer類
package feige.bean;
public class Customer extends Person{
private String customerId;
private String phone;
public Customer(){
}
//構(gòu)建器 用來構(gòu)建一個對象
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);
//this.pwd = pwd ;
return this;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
第二部分在類LoginService創(chuàng)建注冊方法
package feige.service;
import feige.bean.Customer;
import java.util.Scanner;
public class LoginService {
private Scanner sc = null;
public LoginService(Scanner scanner) {
this.sc = scanner;
}
//注冊
public void register() {
System.out.println("請輸入用戶的編號:");
String clientId = 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 sex = sc.next();
System.out.println("請輸入手機(jī)號:");
String phone = sc.next();
Customer customer = Customer.builder().setCustomerId(clientId).Pwd(pwd);
customer.setName(name);
customer.setAge(age);
customer.Pwd(pwd);
customer.setSex(sex);
// 把上面的對象保存到數(shù)組
// CustomerData.save(customer);
}
}