4.3 |
// Filename: Database.java
// Specify package
package com.megabankcorp.system;
// Allow usage of Account class simply by referring to the name Account.
import com.megabankcorp.records.Account;
// Class must be abstract since it has abstract methods.
public abstract class Database {
// Abstract and available from anywhere.
public abstract void deposit(Account acc, long amount);
// Abstract and available from anywhere.
public abstract void withdraw(Account acc, long amount);
// Abstract and only available from package and subclasses.
protected abstract long amount(Account acc);
// Unmodifiable and only available from package.
final void transfer(Account from, Account to, long amount) {
withdraw(from, amount);
deposit(to, amount);
}
}
|