In this exercise you will build a simple banking system according the design shown in Figure 1.   Figure 1. Banking System Class Diagram Create BankAccount class with the following properties: accountNo, balance. This class should have a constructor to initialize these 2 properties. This class should have these methods: deposit(amount): this method adds the amount to the balance withdraw(amount): this method subtracts the amount from the balance toString(): this method return Account # accountNo has QR balance. e.g., Account #123 has QR1000. Export the BankAccount class module as an object.  Create app.js program. Declare accounts variable array and initialize it with the following accounts: accountNo balance 123 1000 234 4000 345 3500 Display the content of the accounts array. Create SavingAccount class that extends BankAccount with an extra property: minBalance and an extra method distributeBenefit(benefitPercentage). This method computes the monthly benefit using the balance += (balance * benefitPercentage). The constructor should extend BankAccount to initialize the minBalance. Also, extend the toString() to indicate that this is a Saving Account. e.g., e.g., Saving Account #123 has QR1000. Test savingAccount in app.js using the same table above and use a minimum balance of 500 for all accounts. Create CurrentAccount class that extends BankAccount with an extra property: monthlyFee and an extra method deductFee(). This method subtracts the monthlyFee from the account balance only if the deducted fee is less than the balance. The constructor should extend BankAccount to initialize the monthlyFee. Also, extend the toString() to indicate that this is a Current Account. e.g., e.g., Current Account #123 has QR1000. Test currentAccount in app.js using the same table above and use a monthly fee of 15 for all accounts. Create Bank class to manage accounts. It should have a property accounts to store the accounts. Also, it should have the following methods:   Method Functionality add(account) Add account (either Saving or Current) to accounts array. getAccount(accountNo) Return an account by Id deleteAccount(accountNo) Delete an account by Id avgBalance() Get the average balance for all accounts sumBalance() Get the sum balance for all accounts serialize() Return accounts as a JSON string deserialize(accountsJson) Takes JSON string representing accounts and returns an array of accounts.   Create app.js program. Declare an instance of Bank class then add the following accounts: accountNo balance type minimumBalance monthlyFee 123 500 Saving 1000   234 4000 Current   15 345 35000 Current   25 456 60000 Saving 1000       Test all the bank methods described above. Display the total balance of all accounts. Go through all the Current accounts and charge the monthly fee Display the total balance of all accounts after charging the monthly fee. Go through all the Saving accounts and distribute the benefit using a 5% benefit. Display the total balance of all accounts after distributing the benefits.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In this exercise you will build a simple banking system according the design shown in Figure 1.

 

Figure 1. Banking System Class Diagram

  • Create BankAccount class with the following properties: accountNo, balance. This class should have a constructor to initialize these 2 properties. This class should have these methods:
    • deposit(amount): this method adds the amount to the balance
    • withdraw(amount): this method subtracts the amount from the balance
    • toString(): this method return Account # accountNo has QR balance. e.g., Account #123 has QR1000.

Export the BankAccount class module as an object. 

  • Create app.js program. Declare accounts variable array and initialize it with the following accounts:

accountNo

balance

123

1000

234

4000

345

3500

Display the content of the accounts array.

  • Create SavingAccount class that extends BankAccount with an extra property: minBalance and an extra method distributeBenefit(benefitPercentage). This method computes the monthly benefit using the balance += (balance * benefitPercentage). The constructor should extend BankAccount to initialize the minBalance. Also, extend the toString() to indicate that this is a Saving Account. e.g., e.g., Saving Account #123 has QR1000.

Test savingAccount in app.js using the same table above and use a minimum balance of 500 for all accounts.

  • Create CurrentAccount class that extends BankAccount with an extra property: monthlyFee and an extra method deductFee(). This method subtracts the monthlyFee from the account balance only if the deducted fee is less than the balance. The constructor should extend BankAccount to initialize the monthlyFee. Also, extend the toString() to indicate that this is a Current Account. e.g., e.g., Current Account #123 has QR1000.

Test currentAccount in app.js using the same table above and use a monthly fee of 15 for all accounts.

  • Create Bank class to manage accounts. It should have a property accounts to store the accounts. Also, it should have the following methods:

 

Method

Functionality

add(account)

Add account (either Saving or Current) to accounts array.

getAccount(accountNo)

Return an account by Id

deleteAccount(accountNo)

Delete an account by Id

avgBalance()

Get the average balance for all accounts

sumBalance()

Get the sum balance for all accounts

serialize()

Return accounts as a JSON string

deserialize(accountsJson)

Takes JSON string representing accounts and returns an array of accounts.

 

  • Create app.js program. Declare an instance of Bank class then add the following accounts:

accountNo

balance

type

minimumBalance

monthlyFee

123

500

Saving

1000

 

234

4000

Current

 

15

345

35000

Current

 

25

456

60000

Saving

1000

 

 

 

  1. Test all the bank methods described above.
  2. Display the total balance of all accounts.
  • Go through all the Current accounts and charge the monthly fee
  1. Display the total balance of all accounts after charging the monthly fee.
  2. Go through all the Saving accounts and distribute the benefit using a 5% benefit.
  3. Display the total balance of all accounts after distributing the benefits.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education