1:public class BankAccount {
 2:    protected int saving; // current amount of money you save in the bank account
 3:    protected String name; // your name
 4:    
5: /** constructor */ 6: public BankAccount(String name, int saving) { 7: this.name = name;
8: this.saving = saving;
9: } 10:
11: /** constructor */ 12: public BankAccount(String name) { 13: this(name,0);
14: } 15:
16: /** deposit money into the account */ 17: public void deposit(int depositAmount) { 18: if(depositAmount >= 0) { // depositAmount must be positive 19: saving+= depositAmount;
20: } 21: } 22:
23: /** withdraw money from the account */ 24: public void withdraw(int withdrawAmount) { 25: /* If the withdrawAmount is negative or 26: there is not enough saving for withdraw 27: do nothing */ 28: if(withdrawAmount >= 0 && withdrawAmount <= saving) {
29: saving-= withdrawAmount;
30: } 31: } 32:
33: /** return saving */ 34: public int getSaving() { 35: return saving;
36: } 37:
38: /** return name */ 39: public String getName() { 40: return name;
41: } 42:
43: public String showInfo() { 44: return "Name: " + name + "\n" +
45: "Saving: " + saving ;
46: } 47:} 48: