updated to generic
This commit is contained in:
@@ -5,15 +5,15 @@ import oop.ch05.secured.SecuredContent;
|
||||
import oop.ch05.secured.SecurityClient;
|
||||
|
||||
public class AccountCard extends MensaCard {
|
||||
private final SecuredContent account;
|
||||
private final SecuredContent<String> account;
|
||||
|
||||
public AccountCard(String key, String account, int password) {
|
||||
super(key, Color.white);
|
||||
this.account = new SecuredContent(password, account);
|
||||
this.account = new SecuredContent<>(password, account);
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return (String) account.getContent();
|
||||
return account.getContent();
|
||||
}
|
||||
|
||||
public void setAccount(SecurityClient client, String account) throws AuthorizationException {
|
||||
|
@@ -4,17 +4,17 @@ import oop.ch05.secured.AuthorizationException;
|
||||
import oop.ch05.secured.SecuredContent;
|
||||
|
||||
public class CashCard extends MensaCard {
|
||||
private final SecuredContent balance;
|
||||
private final SecuredContent<Integer> balance;
|
||||
|
||||
public CashCard(String key, Color color, int password) {
|
||||
super(key, color);
|
||||
balance = new SecuredContent(password, 0);
|
||||
balance = new SecuredContent<>(password, 0);
|
||||
if (color != Color.blue && color != Color.green)
|
||||
throw new IllegalArgumentException("Invalid CashCard color " + color);
|
||||
}
|
||||
|
||||
public int getBalance() {
|
||||
return (Integer) balance.getContent();
|
||||
return balance.getContent();
|
||||
}
|
||||
|
||||
void deposit(VendingMachine client, int cents)
|
||||
|
Reference in New Issue
Block a user