Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub...

70.2K

Verified Solution

Question

Programming

Programming Language: C#

CheckingAccount class

You will implement the CheckingAccount Class in Visual Studio.This is a sub class is derived from the Account class andimplements the ITransaction interface. There are two classvariables i.e. variables that are shared but all the objects ofthis class. A short description of the class members is givenbelow:

CheckingAccount

Class

Fields

$- COST_PER_TRANSACTION = 0.05 :double

$- INTEREST_RATE = 0.005 :double

- hasOverdraft:bool

Methods

+ «Constructor»CheckingAccount(balance = 0 : double, hasOverdraft= false: bool)

+ Deposit(amount :double, person : Person) :void

+ Withdraw(amount :double, person : Person) :void

+ PrepareMonthlyReport(amount :double, person : Person) :void

Fields:

  1. COST_PER_TRANSACTION – this is a classvariable of type double representing the unit cost per transaction.All of the objects on this class will have the same value. Thisclass variable is initialized to 0.05.
  2. INTEREST_RATE – this is a class variable oftype double representing the annual interest rate. All of theobjects on this class will have the same value. This class variableis initialized to 0.005.
  3. hasOverdraft – this is a bool indicating ifthe balance on this account can be less than zero. This privateinstance variable is set in the constructor.

Methods:

  1. public CheckingAccount(double balance = 0,bool hasOverdraft =false ) – This public constructortakes a parameter of type double representing the starting balanceof the account and a bool indicating if this account has over draftpermission. The constructor does the following:
    1. It invokes the base constructor with the string “CK-” and theappropriate argument.
    2. Assigns the hasOverdraft argument to the appropriatefield.
  2. This definition hides the corresponding member in the parentclass because the base class implementation is needed for thismethod as well as the Withdraw() method

    public new void Deposit(double amount,Person person ) – this publicmethod takes two arguments: a double representing the amount to bedeposited and a person object representing the person do thetransaction. The method does the following:
    1. Calls the Deposit() method of the base classwith the appropriate arguments
  3. public voidWithdraw( doubleamount, Person person) – this public method takes two arguments: a doublerepresenting the amount to be withdrawn and a person objectrepresenting the person do the transaction. The method does thefollowing:
    1. Throws an AccountException object if thisperson in not associated with this account.
    2. Throws an AccountException object if thisperson in not logged in.
    3. Throws an AccountException object if thewithdrawal amount is greater than the balance and there is nooverdraft facility.
    4. Otherwise it calls the Deposit() method of thebase class with the appropriate arguments (you will send negativeof the amount)
  4. public overridevoid PrepareMonthlyReport( ) –this public method override the method of the base class with thesame name. The method does the following:
    1. Calculate the service charge by multiplying the number oftransactions by the COST_PER_TRANSACTION (how canyou find out the number of transactions?)
    2. Calculate the interest by multiplying theLowestBalance by theINTEREST_RATE and then dividing by 12
    3. Update the Balance by adding the interest andsubtracting the service charge
    4. In a real-world application, the transaction objects would bearchived before clearing.

      transactions is re-initialized (use theClear() method of the list class)

This method does not take anyparameter nor does it display anything

SavingAccount class

You will implement the SavingAccount Class in Visual Studio.This is a sub class derived from the Account classand implements the ITransaction interface. Again,there are two class variables. A short description of the classmembers is given below:

SavingAccount

Class

→ Account, ITransaction

Fields

$- COST_PER_TRANSACTION :double

$- INTEREST_RATE :double

Methods

+ «Constructor» SavingAccount(balance= 0 : double)

+ Deposit(amount :double, person : Person) :void

+ Withdraw(amount :double, person : Person) :void

+ PrepareMonthlyReport(amount :double, person : Person) :void

Fields:

  1. COST_PER_TRANSACTION – this is a classvariable of type double representing the unit cost per transaction.All of the objects on this class will have the same value. Thisclass variable is initialized to 0.05.
  2. INTEREST_RATE – this is a class variable oftype double representing the annual interest rate. All of theobjects on this class will have the same value. This class variableis initialized to 0.015.

Methods:

  1. public SavingAccount(double balance = 0 ) – Thispublic constructor takes a parameter of type double representingthe starting balance of the account. The constructor does thefollowing:
    1. It invokes the base constructor with the string “SV-” and itsargument.
  2. public new void Deposit(double amount,Person person ) – this publicmethod takes two arguments: a double representing the amount to bedeposited and a person object representing the person do thetransaction. The method calls the Deposit() methodof the base class with the appropriate arguments.
  3. public voidWithdraw( doubleamount, Person person) – this public method takes two arguments: a doublerepresenting the amount to be withdrawn and a person objectrepresenting the person do the transaction. The method does thefollowing:
    1. Throws an AccountException object if thisperson in not associated with this account.
    2. Throws an AccountException object if thisperson in not logged in.
    3. Throws an AccountException object if theintended withdrawal amount exceeds the balance.
    4. Otherwise it calls the Deposit() method of thebase class with the appropriate arguments (you will send negativeof the amount)
  4. public overridevoid PrepareMonthlyReport( ) –this public method override the method of the base class with thesame name. The method does the following:
    1. Calculate the service charge by multiplying the number oftransactions by the COST_PER_TRANSACTION (how canyou find out the number of transactions?)
    2. Calculate the interest by multiplying theLowestBalance by theINTEREST_RATE and then dividing by 12
    3. Update the Balance by adding the interest andsubtracting the service charge
    4. transactions is re-initialized (use theClear() method of the list class)

This method does not take any parameters, nor does it displayanything

Answer & Explanation Solved by verified expert
4.0 Ratings (705 Votes)
Working code implemented in C and appropriate commentsprovided for better understandingHere I am attaching code for these filesmaincsBankcsPersoncsAccountcsSavingAccountcsCheckingAccountcsTransactioncsVisaAccountcsAccountExceptioncsSource code for maincsusing Systemusing SystemCollectionsGenericusing SystemLinqusing SystemTextusing SystemThreadingTasksnamespace Assignment04BankAppclass Programstatic void Mainstring argsConsoleWriteLine START RUNING CODE FROM PROGRAMCStesting the visa accountConsoleWriteLinenAll acountsBankPrintAccountsConsoleWriteLine PASSED PRINT ACCOUNTS ConsoleWriteLinenAll UsersConsoleWriteLineBankPrintPersonsConsoleWriteLineConsoleWriteLine PASSED PRINT PERSONS Person p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10p0 BankGetPersonNarendrap1 BankGetPersonIliap2 BankGetPersonTomp3 BankGetPersonSyedp4 BankGetPersonArbenp5 BankGetPersonPatrickp6 BankGetPersonYinp7 BankGetPersonHaop8 BankGetPersonJakep9 BankGetPersonJoannep10 BankGetPersonNicolettaConsoleWriteLineConsoleWriteLine PASSED PERSON REQUEST p0Login123p1Login234p2Login345p3Login456p4Login567p5Login678p6Login789p7Login890p10Login234p8Login901ConsoleWriteLineConsoleWriteLine PASSED LOGINS a visa accountVisaAccount a BankGetAccountVS100000 as VisaAccountaDoPayment1500 p0aDoPurchase200 p1aDoPurchase25 p2aDoPurchase15 p0aDoPurchase39 p1aDoPayment400 p0ConsoleWriteLineaConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR VS100000VisaAccount aa VisaAccountBankGetAccountVS100001aaDoPayment500 p0aaDoPurchase25 p3aaDoPurchase20 p4aaDoPurchase15 p5ConsoleWriteLineaaConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR VS100001a saving accountITransaction b BankGetAccountSV100002 asITransactionbWithdraw300 p6bWithdraw3290 p6bWithdraw50 p7bWithdraw11111 p8ConsoleWriteLinebConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR SV100002b SavingAccountBankGetAccountSV100003bDeposit300 p3 ok even though p3 is not a holderbDeposit3290 p2bDeposit50 p5bWithdraw11111 p10ConsoleWriteLinebConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR SV100003a checking accountITransaction c BankGetAccountCK100004 asITransactioncDeposit3333 p7cDeposit4044 p7cWithdraw150 p2cWithdraw200 p4cWithdraw645 p6cWithdraw350 p6ConsoleWriteLinecConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR SV100004c BankGetAccountCK100005 as ITransactioncDeposit3333 p8cDeposit4044 p7cWithdraw450 p10cWithdraw500 p8cWithdraw645 p10cWithdraw850 p10ConsoleWriteLinecConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR SV100005a BankGetAccountVS100006 as VisaAccountaDoPayment700 p0aDoPurchase20 p3aDoPurchase10 p1aDoPurchase15 p1ConsoleWriteLineaConsoleWriteLineConsoleWriteLine PASSED TRANSACTIONS FOR SV100006b    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students