FeiGe快递系统----登录模块
第一部分创建Customer类
package feige.bean;
public class Customer extends Person{
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);
//this.pwd = pwd ;
return this;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
第二部分在类LoginService创建注册方法
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("请输入手机号:");
String phone = sc.next();
Customer customer = Customer.builder().setCustomerId(clientId).Pwd(pwd);
customer.setName(name);
customer.setAge(age);
customer.Pwd(pwd);
customer.setSex(sex);
// 把上面的对象保存到数组
// CustomerData.save(customer);
}
}