Question
javascript easy code - please focus on highlited part because i already have some solution to help Step 1 The ask is to build a
javascript easy code - please focus on highlited part
because i already have some solution to help
Step 1
The ask is to build a Banking System app using the given design with mentioned classes.
Step 2
The question has many parts. In compliance with the firm's policies, only first 3 parts can be done in the stipulated time.
The question doesn't mention the programming language for the classes and scripts. Let presume that it's all in Javascript with no server-side code like Java etc.
Let start with the BankAccount class. It's the superclass for SavingAccount and CurrentAccount classes.
The BankAccount can be constructed as below.
class BankAccount { constructor( accountNo, balance) { this.accountNo = accountNo; this.balance = balance; }
deposit( amount ) { this.balance = this.balance + amount; }
withdraw( amount ) { this.balance = this.balance - amount } get toString() { return `Account # ${this.accountNo} has QR ${this.balance}` } }
To export the BankAccount class module as an object
module.exports = {BankAccount: BankAccount};
Step 3
Similarly, SavingAccount and CurrentAccount classes can be constructed as below.
class SavingAccount extends BankAccount { constructor( minBalance ) { super(); this.minBalance = minBalance; } distributeBenefit(benefitPercentage) { this.balance+= balance*benefitPercentage; } get toString() { return `Saving Account # ${this.accountNo} has QR ${this.balance}` } }
class CurrentAccount extends BankAccount { constructor( monthlyFee ) { super(); this.monthlyFee = monthlyFee; } deductFee() { if(this.balance >= this.monthlyFee) { this.balance-= this.monthlyFee; } } get toString() { return `Current Account # ${this.accountNo} has QR ${this.balance}` } }
OPTION 1. Banking App In this exercise you will build a simple banking system according the design shown in Figure 1. Test savingAccount in app.js using the same table above and use a minimum balance of 500 for all accounts. BankAccount accountNo: number Bank accounts : BankAccount[] getAccount/accountNo: number): BankAccount delete Account accountNo: number) avgBalance(): number sumBalance(): number serialize(): string deserialize(accountsJson : string): BankAccount balance number depositamount number) withdraw(amount number) 4) Create CurrentAccount class that extends BankAccount with an extra property: monthlyFee and an extra method deductFeel). 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. 5) Create Bank class to manage accounts. It should have a property accounts to store the accounts. Also, it should have the following methods: toStringo SavingAccount CurrentAccount minBalance number distribute Benefit benefitPercentage : number) toString monthlyFee: number deductFeed toStringo Method Functionality add(account) Add account (either Saving or Current) to accounts array. getAccount(accountNo) Return an account by Id delete AccountlaccountNo) Delete an account by Id avgBalancel) Get the average balance for all accounts sumBalancel) Get the sum balance for all accounts serializel) Return accounts as a JSON string deserialize(accouotsisoo) Takes JSON string representing accounts and returns an array of accounts. Figure 1. Banking System Class Diagram 1) 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. 2) 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. 6) 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. II. III. 3) Create SavingAccount class that extends BankAccount with an extra property: minBalance and an extra method distributeBenefit benefit Percentage). This method computes the monthly benefit using the balance += (balance * benefitPercentage). The constructor should extend BankAccount to initialize the mioBalance. Also, extend the toString() to indicate that 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. IV. V. VI. OPTION 1. Banking App In this exercise you will build a simple banking system according the design shown in Figure 1. Test savingAccount in app.js using the same table above and use a minimum balance of 500 for all accounts. BankAccount accountNo: number Bank accounts : BankAccount[] getAccount/accountNo: number): BankAccount delete Account accountNo: number) avgBalance(): number sumBalance(): number serialize(): string deserialize(accountsJson : string): BankAccount balance number depositamount number) withdraw(amount number) 4) Create CurrentAccount class that extends BankAccount with an extra property: monthlyFee and an extra method deductFeel). 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. 5) Create Bank class to manage accounts. It should have a property accounts to store the accounts. Also, it should have the following methods: toStringo SavingAccount CurrentAccount minBalance number distribute Benefit benefitPercentage : number) toString monthlyFee: number deductFeed toStringo Method Functionality add(account) Add account (either Saving or Current) to accounts array. getAccount(accountNo) Return an account by Id delete AccountlaccountNo) Delete an account by Id avgBalancel) Get the average balance for all accounts sumBalancel) Get the sum balance for all accounts serializel) Return accounts as a JSON string deserialize(accouotsisoo) Takes JSON string representing accounts and returns an array of accounts. Figure 1. Banking System Class Diagram 1) 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. 2) 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. 6) 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. II. III. 3) Create SavingAccount class that extends BankAccount with an extra property: minBalance and an extra method distributeBenefit benefit Percentage). This method computes the monthly benefit using the balance += (balance * benefitPercentage). The constructor should extend BankAccount to initialize the mioBalance. Also, extend the toString() to indicate that 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. IV. V. VIStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started