Say I\'m trying to translate the below Java classes to GNU Smalltalk:
public abstract class Account {
protected String number;
protected Customer cu
You shouldn't bother with some kind of "making class abstract" :). But the closest solution to your question is
abstractMethod [
self subclassResponsibility
]
Now when someone sends a message to your class he'll get an error that this method should be implemented, and you must override it in subclasses.
Yes. All instance vars can be accessed by a subclass.
Ok, so the keyword messages like withdraw: amount can actually have multiple parameters like: withdraw: amount becauseOf: reason. So first of all you make an initialiser:
initWithBalance: aBalance customer: aCustomer number: aNumber [
self init.
balance := aBalance.
customer := aCustomer.
number := aNumber
]
You can keep interest := 0. in main init.
Then, to make your life better, you make a parameterised new and call parameterised init from there.
SavingsAccount class [
newWithBalance: aBalance customer: aCustomer number: aNumber [
^ self new initWithBalance: aBalance customer: aCustomer number: aNumber
]
]