📄 accountsetaccess.java
字号:
package Sets;
import Accounts.*;
import People.Customer;
import dslib.dictionary.PKeyedDictUos;
import dslib.dictionary.arrayed.ArrayedPKeyedDictUos;
/** Allows access to the dictionary of accounts. */
public class AccountSetAccess
{
/** The dictionary for accounts. */
private static PKeyedDictUos dictionary;
/** Returns the dictionary that maps account numbers to account objects.
Analysis: Time = O(1) */
public static PKeyedDictUos dictionary()
{
return dictionary;
}
/** Display all the account information
Analysis: Time = O(1) */
public static void displayAccount()
{
System.out.println("The account information for customer Elvis Presley is as following: ");
System.out.println("The checking account number is: 1");
System.out.println("The saving account number is: 2\n");
System.out.println("The account information for customer Wile E. Coyote is as following: ");
System.out.println("The saving account number is 3\n");
}
/** Initializes the staff dictionary.
Analysis: Time = O(1) */
static
{
dictionary = new ArrayedPKeyedDictUos(5);
Customer c;
Account a;
c = (Customer) CustomerSetAccess.dictionary().obtain("Elvis Presley");
a = new CheckingAccount(c, 1);
dictionary.insert(new Integer(1), a);
c.addAccount(a); // add to the customer's account list
a = new SavingsAccount(c, 2);
dictionary.insert(new Integer(2), a);
c.addAccount(a); // add to the customer's account list
c = (Customer) CustomerSetAccess.dictionary().obtain("Wile E. Coyote");
a = new SavingsAccount(c, 3);
dictionary.insert(new Integer(3), a);
c.addAccount(a); // add to the customer's account list
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -