Reputation: 49
Im new to c# and I've created three accounts for a banking system which are: Everyday, Investment, and Omni. The problem I have is that I cant work out how i will be able to add the Interest rates and fees to the accounts in the class. Below is the requirements for each class:
Everyday Account: No interest, no overdraft, no fees
Investment: Interest rates (varied) paid on all funds, no overdraft allowed, fee incurred for failed transaction.
Omni: Interest rates paid only on balances over $1000; specifies overdraft permitted; fee for failed transactions.
Any help with adding this into my classes and code will be much appreciated. Just really stuck at the moment.
// Everyday Account
class Everyday : Account
{
//field
private double minBalance;
private double maxBalance;
//properties
public double MinBalance
{ get { return this.minBalance; } }
public double MaxBalance
{ get { return this.maxBalance; } }
//constructors
public Everyday(double balance) : base()
{
this.minBalance = 0;
this.maxBalance = 1000000000000;
this.balance = balance;
accountType = "Everyday Account";
}
//methods
}
// Investment Account
class Investment : Account
{
//field
private double minBalance;
private double maxBalance;
//properties
public double MinBalance
{ get { return this.minBalance; } }
public double MaxBalance
{ get { return this.maxBalance; } }
//constructors
public Investment(double balance) : base()
{
this.minBalance = 0;
this.maxBalance = 1000000000000;
this.balance = balance;
accountType = "Investment Account";
}
//methods
}
// Omni Account
class Omni : Account
{
//field
private double minBalance;
private double maxBalance;
//properties
public double MinBalance
{ get { return this.minBalance; } }
public double MaxBalance
{ get { return this.maxBalance; } }
//constructors
public Omni(double balance) : base()
{
this.minBalance = 0;
this.maxBalance = 1000000000000;
this.balance = balance;
accountType = "Omni Account";
}
//methods
}
// Account
class Account : Customer
{
// Fields
private double accountNumber;
protected string accountType;
protected double balance;
protected double deposit;
protected double withdrawal;
// Properties
public string AccountType
{
get { return this.accountType; }
}
public double Withdrawal
{
get { return this.withdrawal; }
set { this.withdrawal = value; }
}
public double Deposit
{
get { return this.deposit; }
set { this.deposit = value; }
}
public double AcctNumber
{ get { return this.accountNumber; } }
public double Bal
{ get { return this.balance; } }
// Creating Random Account Number
public virtual double AccountNumb()
{
Random rand = new Random();
this.accountNumber = rand.Next(100000000, 1000000000);
return accountNumber;
}
//Computes General Balance(resets values)
public virtual double Balance()
{
balance = balance + deposit - withdrawal;
deposit = 0;
withdrawal = 0;
return balance;
}
//Computers Balance when withdrawal equals zero
public virtual double DepositBalance(double input)
{
deposit = input;
withdrawal = 0;
balance = balance + deposit - withdrawal;
return balance;
}
//Computers balance when deposit equals zero
public virtual double WithBalance(double input)
{
withdrawal = input;
deposit = 0;
balance = balance + deposit - withdrawal;
return balance;
}
//displays online banking menu
public virtual void DisplayMenu()
{
Console.WriteLine("Welcome to your online bank account\nPlease choose from the options below: ");
Console.WriteLine("");
Console.WriteLine("1.View Client Info");
Console.WriteLine("");
Console.WriteLine("2. View Account Balance:");
Console.WriteLine(" 2A.Everyday\n 2B.Investment\n 2C.Omni");
Console.WriteLine("");
Console.WriteLine("3.Deposit Funds:\n 3A.Everyday\n 3B.Investment\n 3C.Omni");
Console.WriteLine("");
Console.WriteLine("4.Withdraw Funds:\n 4A.Everyday\n 4B.Investment\n 4C.Omni");
Console.WriteLine("");
Console.WriteLine("5.Exit");
}
}
Upvotes: 1
Views: 1026
Reputation: 113
in Investment Class :` class Investment : Account { //field
private double minBalance;
private double maxBalance;
//add this
private double tax;
//properties
public double MinBalance
{ get { return this.minBalance; } }
public double MaxBalance
{ get { return this.maxBalance; } }
public double Tax{get{return this.tax;}}
//constructors
public Investment(double balance) : base()
{
this.minBalance = 0;
this.maxBalance = 1000000000000;
this.balance = balance*Tax+balance;
accountType = "Investment Account";
}
//methods
}
and in omni class:
class Omni : Account
{
//field
private double minBalance;
private double maxBalance;
private double Tax;
//properties
public double MinBalance
{ get { return this.minBalance; } }
public double MaxBalance
{ get { return this.maxBalance; } }
public double Tax{get{return this.tax;}}
//constructors
public Omni(double balance) : base()
{
this.minBalance = 0;
this.maxBalance = 1000000000000;
if (balance>=1000){this.balance=blance*Tax+balance}
else {this.balance=balance}
accountType = "Omni Account";
}
//methods
}
`
Upvotes: 0