Ad
Code
Diff
  • class Account {
      
      private int balance = 0;
      
      void deposit(int amount){
        balance += amount;
      }
      
      void withdraw(int amount) throws IllegalArgumentException{
        if (amount < 0) {
          throw new IllegalArgumentException("You cannot withdraw negative money!");
        }
        if(amount > balance) {
          throw new IllegalArgumentException("You cannot withdraw more than you have!");
        }
        balance -= amount ;
      }
      
      String getStatement() {
        return String.valueOf(balance);
      }
      
    }
    • class Account {
    • private int balance = 0;
    • void deposit(int amount){
    • balance += amount;
    • }
    • void withdraw(int amount) throws IllegalArgumentException{
    • if (amount < 0) {
    • throw new IllegalArgumentException("You cannot withdraw negative money!");
    • }
    • if(amount > balance) {
    • throw new IllegalArgumentException("You cannot withdraw more than you have!");
    • }
    • balance -= amount ;
    • }
    • String getStatement() {
    • return String.valueOf(balance);
    • }
    • }