Question: please don't forget the UML diagram Q1. Create a java project called Homework3_Account Transactions, with a main class named TestAccount Transactions, and three classes: Account,



Q1. Create a java project called Homework3_Account Transactions, with a main class named TestAccount Transactions, and three classes: Account, Current Account and Transaction, according to the following descriptions: (A). Create the class Transaction according to the following UML diagram: The getter and setter methods for these data felds are provided in the class, but omitted in the UML diagram for brevity. Transaction -date: java.util.Date -type: char - amount: double -balance: double -description: String +Transaction(type: char, amount: double, balance: double, description: String) The date of this transaction The type of the transaction, such as "W for withdrawal, 'D for deposit The amount of the transaction The new balance after this transaction The description of this transaction. Construct a Transaction with the specified date.type, balance, and description (B). Create the class Account as the following: 1. Add all data fields, constructors, and methods of this class as shown in pages 36-37 in the Lab Manual. 2. Add a new private String data field called customerName; and its accessor and mutator methods. (C). Create the class Current Account which inherits the Account class, with the following: 1. Add a new ArrayList data field named transactions of type Transaction, to store the transactions for account objects (i.e. withdraw and deposit operations). 2. Add an arg-constructor that is used to construct an account object with the specified customerName, id, balance, and annualInterest Rate. This constructor must invoke the arg- constructor of Account class. 3. Override the withdraw and deposit methods to add a transaction to the transactions array list. (D). Write the program's main method to do the following: 1. Create an Account object for yourself with annual interest rate 1.5%, a 1000 SR balance, your id (1122), and your name. 2. Deposit 300 SR, and then 400 SR, and then 500 SR to your account. 3. Withdraw 100 SR, and then 200 SR, and then 150 SR from your account. 4. Print account summary that shows account holder name, interest rate, balance, and all transactions. Page 36 Here is Account class : class Account private int id=0; private double balance = 0.0; private static double annuallnterestRate=0.0 private java.util.Date dateCreated; public Account() { dateCreated = new java.util.Date(); } public Account(int id, double balace) { this(); this.id = id; this balance balance 1 public int getid) { return this.id; 3 public double getBalance() { return this.balance: } public double getAnnualinterestRate() { return annualinterestRate: ) public String getDateCreated() { return this.dateCreated.toString(): } public void setidint id) { this.id = id; 1 public void setBalance(double balance) { this balance = balance; } public void setAnnuallnterestRate(double annualinterestRate) { this.annualInterest Rate = annualInterestRate; Page 37 public double get MonthlyInterestRate() { return (annuallnterestRate / 100)/12; 1 public double getMonthlyInterest() { return balance.getMonthlyInterestRate(): 2 public void withdraw(double amount) { this balance -- amount 1 public void deposit(double amount) { this.balance +- amount; 1 ) The Test Class for the above Account Class is: public class Test public static void main(String[] args) { Account account = new Account(1122, 20000): account.setAnnualInterestRate(4.5); account withdraw(2500.0): account.deposit(3000.0): System.out.println("Balance: $" + account.getBalance()); System.out.println("Monthly Interest:* + account.getMonthlyInterest(); System.out.println("Date Created: " + account getDateCreated(); 1 Here is the program's sample output: Customer Name:Abdulrahman Customer ID: 1122 Account Created on: Wed Mar 03 13:52:03 AST 2021 Balance SR: 1750.0 Monthly Interest: 2.1875 Transactions: Date: Wed Mar 03 13:52:04 AST 2021 Type: Deposit Amount: 300.0 Balance: 1300.0 Date: Wed Mar 03 13:52:04 AST 2021 | Type: Deposit Amount: 400.0 Balance: 1700.0 Date: Wed Mar 03 13:52:04 AST 2021 Type: Deposit Amount: 500.0 Balance: 2200.0 Date: Wed Mar 03 13:52:04 AST 2021 Type: Withdraw | Amount: 100.0 Balance: 2100.0 Date: Wed Mar 03 13:52:04 AST 2021 Type: Withdraw | Amount: 200.0 Balance: 1900.0 Date: Wed Mar 03 13:52:04 AST 2021 | Type: Withdraw | Amount: 150.0 Balance: 1750.0 Draw the UML diagram for the classes: Account, CurrentAccount, and Transaction showing all attributes, constructors, and methods of these classes, as well as the Inheritance and Aggregation relationships
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
