Write the Account class in this order: two instance variables, the constructor, then deposit(). The owner's name is passed in to the constructor, and the balance starts at 0. deposit() adds to the balance.
After Account a = new Account("Kim"); and a.deposit(25.5);, the balance is 25.5.
12 strips: P1 to P12
balance += amount; P1owner = name; P2public Account(String name) { P3public class Account { P4} P5public void deposit(double amount) { P6balance = 0.0; P7public void Account(String name) { P8} P9private String owner; P10} P11private double balance; P12Order: P4, P10, P12, P3, P2, P7, P9, P6, P1, P11, P5. Extra: P8
Lines with the same mark can go in either order.
public class Account {
private String owner;
private double balance;
public Account(String name) {
owner = name;
balance = 0.0;
}
public void deposit(double amount) {
balance += amount;
}
} Extra strip: public void Account(String name) {. A constructor has no return type. With void, this is a method named Account, and new Account("Kim") does not compile.