I am having problems with some course work i'm trying to finish off and any help would be appreciated!
I have 3 types of accounts which extend an abstract type "Account".. [CurrentAccount, StaffAccount and MortgageAccount].
I am trying to read in some data from file and create account objects along with user objects to add to hashmaps stored within the program.
When I create account objects I use a temporary variable of type Account and define its subtype dependant on the data read in.
for example:
Account temp=null;
if(data[i].equalsIgnoreCase("mortgage"){
temp= new MortgageAccount;
}
Problem is when I try to call a method belonging to type MortgageAccount..
Do I need a temp variable of each type, StaffAccount MortgageAccount and CurrentAccount and use them coresspondingly in order to use their methods?
Thanks in advance!