Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package practice_2018_0418;
  2.  
  3. /*
  4.  * 1. 請幫自己新增一個編號為"ABC-123"的帳號
  5.  * 2. 存款 2000元
  6.  * 3. 呼叫自己的 balance 變數,看看會發生什麼事情?
  7.  * 4. 呼叫 getBalance() 方法,看看會發生什麼事情?
  8.  * 5. 提款   500元
  9.  * 6. 呼叫 toString() 方法,看看會發生什麼事情?
  10.  * ----------------------------------------------
  11.  * 7. 幫 Liam 建立一個編號為"RRR-777",並開戶同時幫他存5000元進帳戶
  12.  * 8. 用 Laim 呼叫 toString() 方法,看看會發生什麼事情?
  13.  * ----------------------------------------------
  14.  * 9. 如果以上都沒問題,寫一個transfer的方法進行轉帳,參數為account user, amount
  15.  * 10. 讓 Laim 轉帳給自己1000元
  16.  * 11. 呼叫 toString() 方法,看看有沒有轉帳成功
  17.  * */
  18. public class main {
  19.     public static void main(String[] args) {
  20.         account a = new account("CYL", "ABC-123",2000);
  21.         System.out.println(a.getBalance());
  22.  
  23.         a.withdraw(500);
  24.         System.out.println(a.getBalance());
  25.         System.out.println(a.toString());
  26.        
  27.         account b = new account("Liam", "RRR-777", 5000);
  28.         System.out.println(b.toString());
  29.        
  30.        
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement