走上开放之路: Windows 开发人员的 Java Web 支持基础(下)
2009-11-08 00:00:00 来源:WEB开发网
清单 10. 定义 Visual Basic 类
Private theBalance As Currency
Private theAccountNumber As Integer
Public Sub InitAccount (number As Integer, initBal As Currency)
theAccountNumber = number
theBalance = initBal
End Sub
Public Sub Deposit (amount As Currency)
theBalance = theBalance + amount
End Sub
Public Sub Withdrawal (amount As Currency)
theBalance = theBalance - amount
End Sub
Public Property Get Balance() As Currency
Balance = theBalance
End Property
Public Property Get AccountNumber() As Integer
AccountNumber = theAccountNumber
End Property
定义 Java 类
清单 11 使用 Java 语言实现的了 Account 类。
清单 11. Java 语言 Account 类
public class Account {
private double balance;
private int number;
public Account(int number, double balance) {
number = argNumber;
balance = argBalance;
}
public void deposit(double amnt) {
balance += amnt;
}
public void withdrawal (double amnt) {
balance -= amnt;
}
public double getBalance() {
return balance;
}
public int getNumber() {
return number;
}
}
- ››开放的云让业务更“闪亮”
- ››开放源码 CMS 入门,第 1 部分: 下载、安装和开始...
- ››开放源码 CMS 入门,第 2 部分: 通过 Eclipse 构建...
- ››开放源码 CMS 入门,第 3 部分: 构建定制存储
- ››开放源码 CMS 入门,第 5 部分: 为 Jakarta Slide...
- ››开放源码 CMS 入门,第 6 部分: 为 Jakarta Slide...
- ››走上开放之路: Windows 开发人员的 Java Web 支持...
- ››走上开放之路: Windows 开发人员的 Java Web 支持...
- ››开放标准、开放源码和 Domino 6: 通过 Python 和 ...
- ››开放源码-SMTP发信客户端 for Java
- ››开放防火墙端口实现 Robocopy 文件复制
更多精彩
赞助商链接