// Hunter Schafer, CSE 143 // This class represents a bank account for an individual public class BankAccount { private String name; private int id; private double balance; // Constructs a bank account for the user with the // given name and id. Initially has no money. public BankAccount(String name, int id) { this.name = name; this.id = id; this.balance = 0.0; } // pre: amount is non-negative // post: Deposits amount dollars into this account public void deposit(double amount) { balance += amount; } // pre: amount is non-negative and is less than the // current balance // post: Withdraws amount dollars from this account public void withdraw(double amount) { if (balance >= amount) { balance -= amount; } } // post: Returns the current balance public double getBalance() { return balance; } // post: Returns account information as a String public String toString() { return name + " has $" + balance; } }