Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
OTExample ATM/Core
Contents
Core classes of the ATM example
Class Bank
/** * This class represents a very simple bank, only characterized by its name. * */ public class Bank { private String name; public Bank(String _name) { name = _name; } public String getName() { return name; } }
Class Account
/** * This class represents an account. * In this application it is the base class of the ATM.ForeignAccount role * and the SpecialConditions.BonusAccount role. */ public class Account { private int balance; private Bank bank; /** * Constructor of an account object. Gets the owning bank as parameter. */ public Account(Bank _bank) { bank = _bank; } /** * Get the balance of the account. */ public int getBalance() { return balance; } /** * Get the bank of the account. */ public Bank getBank() { return bank; } /** * Debit an amount from the account. */ public boolean debit(int amount) { if (!(amount>balance)) { balance -= amount; return true; } return false; } /** * Credit an amount to the account. */ public void credit(int amount) { balance += amount; } }
Class AccessDeniedException
/** * This exception is thrown if an unauthorized access to an account is tried. */ public class AccessDeniedException extends Throwable { }
as mentioned: nothing really surprising here.