I can't quite follow what you want and I don't really see what the Decorator pattern has got to do with this, but I'm assuming you want something like:
Code:
class Account {
}
class TestingAccountable extends Account {
}
class MyClass {
public Account getAccount(int type) {
Account acc;
if (type == 0) {
acc = new Account();
}
else {
acc = new TestingAccountable();
}
return acc;
}
}
I'm really guessing here as I couldn't follow what you posted and you didn't post any code.
(BTW, it seems really strange that you're even thinking about design patterns if you've only just started Java - did your lecturer talk to you about the Decorator pattern?)
Bookmarks