I am getting the error Cannot create an instance of the abstract class or interface
in a C# tutorial.
It is failing on this line: result = new Account(nameText, addressText, balance);
Here is my class:
public abstract class Account : IAccount
{
//---------------------------------------------------------------
// Constructor
//---------------------------------------------------------------
public Account(string inName, string inAddress, decimal inBalance)
{
name = inName;
address = inAddress;
balance = inBalance;
}
public Account(string inName, string inAddress) :
this(inName, inAddress, 0) // 'this ties this alternate constructor back to the original constructor (directly above)
{
}
public Account(string inName) : // 'this ties this alternate constructor back to the original constructor (directly above)
this(inName, "Not Supplied", 0)
{
}
//---------------------------------------------------------------
// Properties
//---------------------------------------------------------------
// * * * * * * * *
//global account constraints
private static decimal minIncome = 10000;
private static int minAge = 18;
// * * * * * * * *
//personal details
private string name;
private string address;
// * * * * * * * *
//account details
public int AccountNumber;
public static decimal InterestRateCharged;
public AccountState State;
private decimal balance = 0;
public int Overdraft;
//---------------------------------------------------------------
// Methods
//---------------------------------------------------------------
// loads the account
public static Account Load(string filename)
{
Account result = null;
System.IO.TextReader textIn = null;
try
{
textIn = new System.IO.StreamReader(filename);
string nameText = textIn.ReadLine();
string addressText = textIn.ReadLine();
string balanceText = textIn.ReadLine();
decimal balance = decimal.Parse(balanceText);
result = new Account(nameText, addressText, balance);
}
catch
{
return null;
}
finally
{
if (textIn != null) textIn.Close();
}
return result;
}
};
Here is my interface:
public interface IAccount
{
// account info
int GetAccountNumber();
string GetName();
decimal GetBalance();
// account actions
void PayInFunds(decimal amount);
bool WithdrawFunds(decimal amount);
string RudeLetterString();
}