는 I는 다음의 3 개 가지 종류가 있지만, 어떤 이유로 I 트랜잭션의 유형 및 양, I도 출력 할 수 없다 거래 내역program.cs에서 문자열에 전체 정보를 어떻게 표시 할 수 있습니까?
CurrentAccount의 C1 = 새로운 CurrentAccount ("234555"(1000) 234, TransactionType.Deposit을 표시 할 수없는); // 굵게 표시된 부분은 표시되지 않습니다.
아래 출력을 참조하십시오. 234545 계좌 번호 100 초과 인출. System.Collections.ArrayList 트랜잭션 기록입니다.
어떻게 거래 내역을 올바르게 표시 할 수 있습니까? 234555 계좌 번호 1000 overdraft.System.Collections.ArrayList 거래 내역 :
전체 클래스 아래의 콘솔에서abstract class BankAccount
{
protected string AccountNumber { get; } // read property
protected double Balance { get; set; } //read and write property
public BankAccount(string _accountNumber)
{
this.AccountNumber = _accountNumber;
this.Balance = 0;
}
public virtual void MakeDeposit(double amount)
{
Balance = Balance + amount;
}
public virtual void MakeWithdraw(double amount)
{
Balance = Balance - amount;
}
}
}
class CurrentAccount : BankAccount
{
private double OverdraftLimit { get; } // read only property
public ArrayList TransactionHistory = new ArrayList();
public CurrentAccount(string AccountNumber, double OverdraftLimit, double amount, TransactionType type) : base(AccountNumber)
{
this.OverdraftLimit = OverdraftLimit;
TransactionHistory.Add(new AccountTransaction(type, amount));
}
public override void MakeDeposit(double amount) // override method
{
Balance += amount;
TransactionHistory.Add(new AccountTransaction(TransactionType.Deposit, amount));
}
public override void MakeWithdraw(double amount)
{
if (Balance + OverdraftLimit > 0)
{
Balance -= amount;
TransactionHistory.Add(new AccountTransaction(TransactionType.Withdrawal, amount));
}
else
{
throw new Exception("Insufficient Funds");
}
}
public override string ToString()
{
// print the transaction history too
return AccountNumber + " account number " + OverdraftLimit + " overdraft." + TransactionHistory + " Transaction history.";
}
}
}
{
enum TransactionType
{
Deposit, Withdrawal
}
class AccountTransaction
{
public TransactionType type { get; private set; } // deposit/withdrawal
private double Amount { get; set; }
public AccountTransaction (TransactionType type, double _amount)
{
this.type = type;
this.Amount = _amount;
}
public override string ToString()
{
return "type" + type + "amount" + Amount;
}
}
}
class Program
{
static void Main(string[] args)
{
CurrentAccount c1 = new CurrentAccount("234555",1000, 234, **TransactionType.Deposit)**; // this part is not displayed
CurrentAccount c2 = new CurrentAccount("234534", 12000, 345, **TransactionType.Withdrawal)**; // this part is not displayed
CurrentAccount c3 = new CurrentAccount("234545", 100, 456, **TransactionType.Withdrawal)**; // this part is not displayed
Console.WriteLine(c1);
Console.WriteLine(c2);
Console.WriteLine(c3);
}
}
}
출력을 참조하십시오. 234534 계좌 번호 12000 overdraft.System.Collections.ArrayList 거래 내역입니다. 234545 계좌 번호 100 overdraft.System.Collections.ArrayList 거래 내역입니다.
올바른 정보를 출력 할 수 있도록 도와주세요.
[ask]를 읽고 코드의 형식을 올바르게 지정하십시오. –