WEB开发网
开发学院软件开发Java 走上开放之路: Windows 开发人员的 Java Web 支持... 阅读

走上开放之路: Windows 开发人员的 Java Web 支持基础(下)

 2009-11-08 00:00:00 来源:WEB开发网   
核心提示: 清单 10. 定义 Visual Basic 类PrivatetheBalanceAsCurrencyPrivatetheAccountNumberAsIntegerPublicSubInitAccount(numberAsInteger,initBalAsCurrency)theAccount


清单 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; 
   } 
} 

上一页  1 2 3 4 5 6 7  下一页

Tags:走上 开放 之路

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接