我是 c# 的新手,我为银行系统创建了三个帐户,它们是:Everyday、Investment 和 Omni。我遇到的问题是我无法弄清楚如何将利率和费用添加到班级账户中。以下是每个班级的要求:
日常账户:无利息、无透支、无费用
投资:所有资金支付的利率(可变),不允许透支,交易失败产生的费用。
Omni:仅对超过 1000 美元的余额支付的利率;指定允许透支;交易失败的费用。
将不胜感激将其添加到我的课程和代码中的任何帮助。只是此刻真的卡住了。
// 日常账户
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
}
// 投资账户
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
}
// 全方位账户
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
}
// 帐户
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");
}
}