⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 companycallbackimpl.java

📁 用java写的股票交易游戏
💻 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 + -