Question: Create a Class Diagram that corresponds to the Java code shown below. The answer shall only include what is shown in the code. Add the


Create a Class Diagram that corresponds to the Java code shown below. The answer shall only include what is shown in the code. Add the finished Class Diagram as an image in your file. public class Main { public static void main(String[] args) { Person p = new Person( name: "Anna", address: "An address 1"); Account a = new Account(p); a.deposit( amount 500); p = Person. changeName(p, name: "Kalle"); Account b = new Account(p); b.deposit( amount: 200); b.withdraw( amount 100); } } public class Person { public final String name; public final String address; public Person(String name, String address) { this.name = name; this.address = address; } public static Person changeName (Person p, String name) { return new Person(name, p.address); } } public class Account { private static int nextID = 1; public final int account Number; public final Person owner; private double balance; public Account (Person owner) { this.owner = owner; account Number = nextID++; balance = 0; } public void deposit(double amount) { if (amount >= 0) { balance += amount; } else { throw new IllegalArgumentException("The amount must be positive"); } } public void withdraw(double amount) { if (amount >= 0 && amount balance) { balance = amount; } else { throw new IllegalArgumentException ("The amount must be >= 0 and
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
