Given: UML diagram of an Account object Below. Use Java progaramming Language. Note: The static variables/data fields and methods in UML class diagrams are underlined. Create an Account Object project. 1. Design an Account class and use the provided UML diagram to code the instance fields, constructors and methods. Note: The type of accounts are 1 (Savings) or 2 (Cheque) The constructor must assign the values of the parameters to the data fields/instance variables. The static field must be increased by one in the constructor. The setAccNumber() is a private void method. The account number must consist of the first 3 letters of the name of the account holder, the digit indicating the type of account and #-character and a 3-digit random value. This method must be called from the constructor. The makeDeposit() method must add the amount received as a parameter to the balance if the value received is not a negative value. The withdrawAmount() method must check whether the balance allows for the amount to be withdrawn. There must always be a minimum amount of R 100.00 in an account. If there is not enough money in the account to do the transaction, return the boolean value of false, else return true and subtract the amount from the balance. The toString() method must compile a string to display all the attributes of the object on one line. Example: FRA1#534 Frank 1 R 600.00 Declare a static integer variable to count the number of Account objects being instantiated (created). Add code to both the constructors to increment the static variable when an object is instantiated. 2. Design a testAccounts class. Do the following: Declare an array called arrAccounts of 20 Account type objects in the main method. Write a static method in the test class called fillArray() to receive the array. See Par 9.10 and 9.11 – how to transfer objects to a static method in the main method. Use a while loop to enter the information (name of the account holder, type of account (1 or 2) and amount) of a number of accounts. For each account create an object and save the object in the array. Return the array to the main method. Call the static fillArray() method from the main method. Write another static method called displayArray() to receive the array and display a numbered list of the accounts using a for loop and the toString() method. In the main method, use a loop to do transactions. First, ask the user whether a transaction must be done or not (loop). If Yes call the displayArray() method to show the numbered list of accounts. Ask the user to enter the number of the account on the list. Then ask the type of transaction (W to withdraw or D for deposit) to be done and the amount. Call the relevant method to do the relevant transaction. If it is a withdrawal transaction and there is not enough money in the account, display a suitable message. Otherwise, display “Transaction done”. Display the accountholder’s updated balance using thegetBalance() method. Ask the user whether another transaction must be done. Keep on doing transactions until the user terminates the loop by indicating that there are no more transactions to be done.

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

Given: UML diagram of an Account object Below.

Use Java progaramming Language.

Note: The static variables/data fields and methods in UML class diagrams are underlined.

 

Create an Account Object project.

1. Design an Account class and use the provided UML diagram to code the instance fields, constructors and methods.

Note:

The type of accounts are 1 (Savings) or 2 (Cheque)

The constructor must assign the values of the parameters to the data fields/instance variables.

The static field must be increased by one in the constructor.

 

The setAccNumber() is a private void method. The account number must consist of the first 3 letters of the name of the account holder, the digit indicating the type of account and #-character and a 3-digit random value. This method must be called from the constructor.

 

The makeDeposit() method must add the amount received as a parameter to the balance if the value received is not a negative value.

 

The withdrawAmount() method must check whether the balance allows for the amount to be withdrawn. There must always be a minimum amount of R 100.00 in an account. If there is not enough money in the account to do the transaction, return the boolean value of false, else return true and subtract the amount from the balance.

 

The toString() method must compile a string to display all the attributes of the object on one line.

Example:

 

FRA1#534  Frank  1  R  600.00

 

Declare a static integer variable to count the number of Account objects being instantiated (created). Add code to both the constructors to increment the static variable when an object is instantiated.

 

2. Design a testAccounts class. Do the following:

 

Declare an array called arrAccounts of 20 Account type objects in the main method.

 

Write a static method in the test class called fillArray() to receive the array. See Par 9.10 and 9.11 – how to transfer objects to a static method in the main method.

 

Use a while loop to enter the information (name of the account holder, type of account (1 or 2) and amount) of a number of accounts. For each account create an object and save the object in the array. Return the array to the main method.

 

 

Call the static fillArray() method from the main method.

 

Write another static method called displayArray() to receive the array and display a numbered list of the accounts using a for loop and the toString() method.

 

In the main method, use a loop to do transactions.

First, ask the user whether a transaction must be done or not (loop). If Yes call the displayArray() method to show the numbered list of accounts.

 

Ask the user to enter the number of the account on the list.

Then ask the type of transaction (W to withdraw or D for deposit) to be done and the amount.

Call the relevant method to do the relevant transaction. If it is a withdrawal transaction and there is not enough money in the account, display a suitable message. Otherwise, display “Transaction done”.

Display the accountholder’s updated balance using thegetBalance() method.  

Ask the user whether another transaction must be done.

Keep on doing transactions until the user terminates the loop by indicating that there are no more transactions to be done.

Account
-accNumber:string
-holder:string
-balance:double
-ассТуре:int
-numobjects:int
+Account(holder:string, balance:double, accType:int)
+getNumObjects():int
+getAccNumber():string
+getHolder():string
+getBalance():double
+getAccType():int
-setAccNumber():void
+setHolder(holder:string ):void
+setAccType(accType:int ):void
+makeDeposit(amount:double):void
+withdrawAmount(amount:double):boolean
+toString():string
Transcribed Image Text:Account -accNumber:string -holder:string -balance:double -ассТуре:int -numobjects:int +Account(holder:string, balance:double, accType:int) +getNumObjects():int +getAccNumber():string +getHolder():string +getBalance():double +getAccType():int -setAccNumber():void +setHolder(holder:string ):void +setAccType(accType:int ):void +makeDeposit(amount:double):void +withdrawAmount(amount:double):boolean +toString():string
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE 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