1. Engineering
  2. Computer Science
  3. class d extends c 14 given the following interface 21...

Question: class d extends c 14 given the following interface 21...

Question details

class D extends C 14. Given the following interface: (21 pts) public interface Walletlnterface ( public double getBalance(): public void addMoney(double amount); public double spendMoney(double amount); public String toStringl): Write three classes named APerson, Wallet, and BankAccount. The person class should have name, iD, Wallet, and BankAcount as private members. The wallet class should have a private double amount member and implements Walletinterface The BankAcount should have the balance, account number as its private members. Write constructor, setters, getters and toString() for all three classes. In a person constructor Create Object of BankAcount with initial balance of 100.0 dollars. Create Object of Wallet as well. Provide methods (API) to help the user of you classes to do their job as follows: (see main) public class Driver 9public static void main(String I ] args) APerson lisa new APerson (Lisa,1111); APerson jack new APerson(Jack, 2222); / / check the lisa Wallet if it has no money, withdraw, 20 dollar from her bank, add to her wallet. // print the result using toString) // do the same for Jack except withdraw 40 dollar, print the result. // Write statement to see which one Lisa or Jack has more money.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution