?? customer.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 + -