⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customer.java

📁 本程序用Java语言描述了一个基本的银行管理系统
💻 JAVA
字号:
package banking.domain;

public class Customer implements Comparable {
	public final static int MAX_CAPACITY = 10;

	public final static int STRING_SIZE = 32;

	private String firstName;

	private String lastName;

	private Account[] account;

	private int numOfAccounts;

	public Customer(){
		this.account = new Account[Customer.MAX_CAPACITY];
		this.numOfAccounts = 0;
	}
	public Customer(String f, String l) {
		this();
		this.firstName = f;
		this.lastName = l;
	}

	public String getFirstName() {
		return this.firstName;
	}
	
	public void setFirstName(String name){
		this.firstName = name;
	}
	
	public void setLastName(String name){
		this.lastName = name;
	}
	
	public void setNum(int num){
		this.numOfAccounts = num;
	}

	public String getLastName() {
		return this.lastName;
	}

	public boolean addAccount(Account account) {
		if (this.numOfAccounts != Customer.MAX_CAPACITY) {
			this.account[this.numOfAccounts++] = account;
			return true;
		}
		return false;
	}

	public Account getAccount(int index) {
		if (index < 0 || index >= Customer.MAX_CAPACITY)
			return null;
		return this.account[index];
	}

	public int getNumOfAccounts() {
		return this.numOfAccounts;
	}

	public int compareTo(Customer o) {
		int order = this.lastName.compareTo(o.getLastName());
		if (order != 0) {
			return order;
		} else {
			order = this.firstName.compareTo(o.getFirstName());
			return order;
		}
	}

	public int compareTo(Object o) {
		if (o instanceof Customer)
			return this.compareTo(o);
		else
			return 0;
	}
	
	public static void main(String[] args){
		Customer c1 = new Customer("jay", "zhou");
		Customer c2 = new Customer("bay", "ahou");
		System.out.println(c1.compareTo(c2));
	}

	/*public int getByteSize() {
		return (4 + Customer.STRING_SIZE * 2 + this.numOfAccounts * 20);
	}*/
}

⌨️ 快捷键说明

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