customerreport.java

来自「本程序用Java语言描述了一个基本的银行管理系统」· Java 代码 · 共 49 行

JAVA
49
字号
package banking.reports;

import banking.domain.*;
import java.text.NumberFormat;

public class CustomerReport {

	public void generateReport() {
		NumberFormat currency_format = NumberFormat.getCurrencyInstance();

		Bank bank = Bank.getBank();
		
		bank.sortCustomers();

		Customer customer;

		System.out.println("\t\t\tCUSTOMERS REPORT");
		System.out.println("\t\t\t================");

		for (int cust_idx = 0; cust_idx < bank.getNumOfCustomers(); cust_idx++) {
			customer = bank.getCustomer(cust_idx);

			System.out.println();
			System.out.println("Customer: " + customer.getLastName() + ", "
					+ customer.getFirstName());

			for (int acct_idx = 0; acct_idx < customer.getNumOfAccounts(); acct_idx++) {
				Account account = customer.getAccount(acct_idx);
				String account_type = "";

				// Determine the account type
				if (account instanceof SavingsAccount) {
					account_type = "Savings Account";
				} else if (account instanceof CheckingAccount) {
					account_type = "Checking Account";
				} else {
					account_type = "Unknown Account Type";
				}

				// Print the current balance of the account
				System.out.println("    " + account_type
						+ ": current balance is "
						+ currency_format.format(account.getBalance()));
			}
		}
	}

}

⌨️ 快捷键说明

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