closestfind.java

来自「java写的Archreport」· Java 代码 · 共 41 行

JAVA
41
字号
/**	File Name:    	ClosestFind.java	Author:	黄增博   #B02251132	Date:		March 20 2004	Description:	The ClosestFind class is used to find the artifact closest                        to the provided ArchFind object.**/class ClosestFind{	private ArchFind item;    // the provide item	private ArchFind closestToItem; // the item closest to 'item'	private double distance;	// the distance between the two items	public ClosestFind(ArchFind it){		item = it;		closestToItem = null;	//null indicates there are no other items		distance = Double.NaN;  // initialize distance to not a number;	}	/* If the find object is closer to the item object than	* closestToItem object, then replace closestToItem by find	*/	public void update(ArchFind find){		//if there is no current item, then find becomes closestToItem		if(closestToItem==null){			closestToItem = find;			distance = closestToItem.distanceBetween(item);			return;		}		/*provide the implementation that check distance,		* and updates closestToItem if necessary		*/                else                if(closestToItem.distanceBetween(item)>find.distanceBetween(item))                closestToItem=find;		}	public ArchFind getClosest(){		return closestToItem;//return closest to item	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?