📄 companycallbackimpl.java
字号:
// jingjing Wang
//420 final project
import java.rmi.*;
import java.rmi.server.*;
public class CompanyCallbackImpl extends UnicastRemoteObject implements
CompanyCallBackInterface {
private Company thiscompany;
/** Constructor */
public CompanyCallbackImpl(Object company) throws RemoteException {
thiscompany = (Company)company;
}
public void SellStock(int n,double bid){ //the company will sell the stock,n means the player wants to buy
int m=thiscompany.GetStock()-n;
thiscompany.SetStock(m);
double j=(bid*n+thiscompany.GetStock()*thiscompany.Getprice())/(thiscompany.GetStock()+n);
double k=(double)Math.round(j*100)/100;
thiscompany.SetPrice(k);
thiscompany.update();
}
public void BuyStock(int n,double bid){ // the company will buy the stock; n means the player wants to sell
int m=thiscompany.GetStock()+n;
thiscompany.SetStock(m);
double j=(bid*n+thiscompany.GetStock()*thiscompany.Getprice())/(thiscompany.GetStock()+n);
double k=(double)Math.round(j*100)/100;
thiscompany.SetPrice(k);
thiscompany.update();
} //endBuyStock
public int getStock(){
return thiscompany.stock;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -