package FeiGe;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.util.Scanner;
public class LoginService {
private Scanner scanner = null;
public LoginService(){ }
public LoginService(Scanner scanner){
this.scanner = scanner;
}
public void login(){
System.out.println("選擇身份:1.用戶昼激,2.快遞員");
int role = scanner.nextInt();
System.out.println("請(qǐng)輸入用戶的id:");
String id = scanner.next();
System.out.println("請(qǐng)輸入用戶的密碼:");
String pwd = scanner.next();
if ( 1 == role ){
System.out.println("用戶登錄");
invokeCustomerService(id , pwd);
} else if ( 2 == role){
System.out.println("快遞員登陸功能暫時(shí)關(guān)閉");
}
}
// 登錄
public void invokeCustomerService(String id , String pwd){
// 在數(shù)組中查詢?cè)撚脩羰欠翊嬖? Customer customer = CustomerData.get(id , pwd);
if ( null == customer){
System.out.println("數(shù)據(jù)庫(kù)中沒(méi)有該用戶無(wú)法登錄");
return; // 提前中斷程序
}
//找到用戶,進(jìn)入對(duì)應(yīng)的功能
}
// 注冊(cè)
public void resgister(Scanner sc ) {
System.out.println("請(qǐng)輸入用戶的編號(hào)");
String clientId = sc.next();
System.out.println("請(qǐng)輸入用戶密碼");
String pwd = sc.next();
System.out.println("請(qǐng)輸入用戶名");
String name = sc.next();
System.out.println("請(qǐng)輸入年齡");
int age = sc.nextInt();
System.out.println("請(qǐng)輸入性別");
String sex = sc.next();
System.out.println("請(qǐng)輸入用戶的手機(jī)號(hào)");
String phone = sc.next();
Customer customer = new Customer( name , sex , pwd , age , clientId , phone);
CustomerData.save(customer);
}
}