As mentioned, Java, does not have good support for singular objects as described in chapter 2. In most cases, objects are instances of classes so to create objects like Account_1010
representing the account of John Smith, we use class Account,
which may be defined as follows:
class Account {
Account(Customer ow) {
owner = ow;
}
Customer owner;
float balance;
float interestRate;
addInterest() {
balance = balance + (balance * interestRate) / 100;
}
deposit(real amount) {
balance = balance + amount;
}
real withdraw(real amount) {
balance = balance - amount;
return balance;
}
Explain class Account, the constructor, introduce main and show how to create instances.
Show class Customer.