?? customerio.java
字號:
package banking.io;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import banking.domain.Customer;
public class CustomerIO {
public static void writeCustomer(Customer customer, DataOutput output)
throws IOException {
output.writeInt(customer.getNumOfAccounts());
FixedLengthStringIO.writeFixedLengthString(customer.getFirstName(),
Customer.STRING_SIZE, output);
FixedLengthStringIO.writeFixedLengthString(customer.getLastName(),
Customer.STRING_SIZE, output);
for (int i = 0; i < customer.getNumOfAccounts(); ++i) {
AccountIO.writeAccount(customer.getAccount(i), output);
}
}
public static Customer readCustomer(DataInput input) throws IOException {
int numOfAccounts = input.readInt();
String firstName = FixedLengthStringIO.readFixedLengthString(
Customer.STRING_SIZE, input);
String lastName = FixedLengthStringIO.readFixedLengthString(
Customer.STRING_SIZE, input);
Customer customer = new Customer(firstName, lastName);
for (int i = 0; i < numOfAccounts; ++i)
customer.addAccount(AccountIO.readAccount(input));
return customer;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -