Question: C# Programming Lnaguage Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e.,
C# Programming Lnaguage



Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes Savings Account and CheckingAccount that inherit from class Account 1) Base class Account should include: i) one private instance variable of type string to represent the account number (accNumber). ii) one private instance variable of type decimal to represent the account balance. 2) The Account class should provide a constructor with two parameters: i) first parameter to receive account number and uses it to initialize the private instance variable using public property AccNumber. ii) second parameter that receives an initial balance and uses it to initialize the private instance variable using a public property Balance. The property Balance should validate the initial balance to ensure that it is greater than or equal to 0.0; if not, ignore the initial balance and display the message "Account initial balance amount should be a positive value." The Account class should also provide a get accessor in property Balance that returns the current balance. 3) The class Account should provide two public methods. i) Method Credit should add an amount to the current balance. 420-331-VA: Application Development-1 Assignment 01 Page 1 of 3 ii) Method Debit should withdraw money from the Account and ensure that the debit amount does not exceed the Account's balance. If it does, the balance should be left unchanged, and the method should display the message "Debit amount exceeded account balance." [Hint: Define Account's Debit method so that it returns a bool indicating whether money was withdrawn.] 5) Derived class Savings Account should inherit the functionality of class Account, but also include a private decimal instance variable indicating the interest rate (percentage) assigned to the Account 6) Savings Account's constructor should receive three parameter values, the account number, the initial balance, and an initial value for the interest rate and uses it to initialize the private instance variable using a public property InterestRate. 7) Savings Account should provide public method Calculate Interest that returns a decimal indicating the amount of interest earned by an account. Method CalculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: SavingsAccount should inherit methods Credit and Debit without redefining them.] 8) The class SavingsAccount should redefine public method Display Account, so that it display values of three instance variables in tabular form as shown below, using C# 6 mechanism String Interpolation" to insert values in string literals to create formatted strings. SAVING ACCOUNT 8753124 Account Number Balance Amount Interest Rate $537.68 $4.13 9) Derived class CheckingAccount should inherit functionality of class Account and include a private decimal instance variable that represents the fee charged per transaction. 10) CheckingAccount's constructor should receive three parameter values, the account number, the initial balance, as well as a parameter indicating a fee amount and uses it to initialize the private instance variable using a public property Fee. 11) Class Checking Account should redefine methods Credit and Debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. CheckingAccount's versions of these methods should invoke the base-class Account version to perform the updates to an account balance. 420-331-VA: Application Development-1 Assignment 01 Page 2 of 3 12) Checking Account's Debit method should charge a fee only if money is actually withdrawn (i.c., the debit amount does not exceed the account balance). (Hint: Define Account's Debit method so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.] 13) The class CheckingAccount should redefine public method DisplayAccount, so that it display values of three instance variables in tabular form as shown below, using C# 6 mechanism "String Interpolation to insert values in string literals to create formatted strings. After defining the classes in this hierarchy, write a driver application that creates objects of each class and tests their methods. 14) Add interest to the SavingsAccount object by first invoking its Calculatelnterest method, then passing the returned interest amount to the object's Credit method and display the account current balance before and after interest amount credit to the account balance. 15) Perform credit and debit transactions to CheckingAccount object by calling Credit and Debit methods of the Checking Account class, and display the account current balance before and after each credit and / or debit transaction
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
