customer.java

来自「远程电子考试系统」· Java 代码 · 共 71 行

JAVA
71
字号
package fangsoft.testcenter.model;

import fangsoft.testcenter.model.Profile;



public class Customer {
	private static Customer[] customers;
	public static  String[][] CUSTOMER_DATA={
	{
		"bill",//name
		"fangsoft",//password
		"fangsoft.org@gmail.com",//email
		"china","beijing","beijing","beijing",//address
		"100081",//postcode
		"13910797448"//phone
		},
		{	
		"fangsoft",
		"fangsoft",
		"fangsoft.java@gmail.com",
		"china","peking","peking","peking",
		"100081",
		"13910797448"
		}
	};
	private String name;
	
	
	static{
		int size=CUSTOMER_DATA.length;
		customers=new Customer[size];
		for(int i=0;i<size;i++){
			String[] cust=CUSTOMER_DATA[i];
			Customer c=new Customer();
			Profile p=new Profile(cust[2],cust[1]);
			c.setProfile(p);
			c.setName(cust[0]);
			customers[i]=c;
		}
	}
	private Profile profile;
	
	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public static boolean login(String userId,String password){
		for(int i=0;i<customers.length;i++){
			Profile p=customers[i].getProfile();
			if(p.getUserId().equals(userId) &&
			   p.getPassword().equals(password)){
				return true;
			}
		}
		return false;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?