Chuỗi bài: Angelia
java
25 dòng
· Cập nhật 2026-09-27
Account.java
Angelia/Java/Week_6_7/code/01_encapsulation/Account.java
/**
* 帳戶介面(interface):只描述「能做什麼」(契約),完全不描述「怎麼做」。
*
* 任何 implements Account 的類別都必須提供這三個方法,
* 而使用 Account 的程式碼只需要認識這份契約即可。
*/
public interface Account {
/**
* 存入 amount。
* @param amount 前置條件:amount >= 0
*/
void deposit(int amount);
/**
* 提出 amount。
* @param amount 前置條件:0 <= amount <= getBalance()
*/
void withdraw(int amount);
/**
* @return 目前餘額,後置條件:回傳值 >= 0
*/
int getBalance();
}
Bài viết liên quan
Angelia
haskell
EN
Cập nhật 2026-02-03
Adding.hs
Adding.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Adding.hs).
Đọc bài viết →
Angelia
haskell
EN
Cập nhật 2026-02-03
Area.hs
Area.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Area.hs).
Đọc bài viết →
Angelia
haskell
EN
Cập nhật 2026-02-03
Chess.hs
Chess.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Chess.hs).
Đọc bài viết →
Angelia
haskell
EN
Cập nhật 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/ChessGraphics.hs).
Đọc bài viết →
Angelia
haskell
EN
Cập nhật 2026-02-03
Examples.hs
Examples.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Examples.hs).
Đọc bài viết →
Angelia
haskell
EN
Cập nhật 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Fibonacci.hs).
Đọc bài viết →