JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » 違規輔導區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
話題被移動
該話題已被移動 - tekwei , 2005-03-14 21:20
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
無標籤
作者 有關Method的問題
kerwinchen2000





發文: 9
積分: 0
於 2005-03-14 20:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Here is a class which defines a bank account: class Account
{
private double theBalance = 0.00; // Balance of account
private String theName = "";


public Account( String name, double openingBalance )
{
theBalance = openingBalance;
theName = name;
}


public double getBalance()
{
// assert theBalance >= 0.00;
return theBalance;
}


public String getName()
{
return theName;
}


public double withdraw( final double money )
{
// assert theBalance >= 0.00;
if ( theBalance >= money )
{
theBalance = theBalance - money;
return money;
} else {
return 0.00;
}
}


public void deposit( final double money )
{
// assert theBalance >= 0.00;
theBalance = theBalance + money;
}
}


This class has the following methods: Account (String name, double openingBalance) - The constructor that sets the name and opening balance in the account.
String getName () - Get the account holder's name
double getBalance () - Returns the amount of money held in the account
double withdraw (double amount) - Withdraws the specified amount from the account if possible. The amount withdrawn is returned,
void deposit (double amount) - Deposits the specified amount of money into the account.


Write a new class BankStats that has the following methods: BankStats (Account accounts[]) - The constructor that sets the accounts to be processed.
double total (double amount) - Return the sum of money in all accounts whose balance is more than the specified amount

我的constructor是
public BankStats( Account accounts[] )
{
bs=accounts;

}
要如何寫出一個完整的Method : double total (double amount) - Return the sum of money in all accounts whose balance is more than the specified amount ???


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
577 有關Method的問題 kerwinchen2000 1936 2005-03-14 20:09
» JWorld@TW »  違規輔導區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8