@ 1 may be generated having a specific coordinate point object 2 // provided a method may be provided three coordinates // 3. The method provides a point from the origin can be calculated from the square // The above three programming

@ 1 may be generated having a specific coordinate point object 

// 2 provided a method may be provided three coordinates 

@ 3 provided that the pitch can be calculated from the square of the origin 
// according to the above three programming 
class Point { 
	Double x, y, z; // define a point (point) point class used to represent three-dimensional space (three-coordinate) as in claim 
	
	point (Double the _x, _y Double, Double _z) { 
		X = the _x; 
		Y = _y; 
		_z = Z; 
	.} can be generated. 1 // point object having a specific coordinate 
	
	void setX (Double the _x) { 
		X = the _x; 
	} 
	void setY (Double _y) { 
		Y = _y; 
	} 
	void setZ (Double _z) { 
		Z = _z; 
	.} // 2 provides three coordinates may be provided a method 
	
	Double getDistance (Point P) { 
		return (X - PX) * (xp.x) + (yp.y) * (yp.y) + (ZP. z) * (zp.z); 
	.} //. 3 provide a method for calculating the square of the distance from the origin pitch 
} 

public class TestPoint { 
	public static void main (String [] args) { 
		Point P = new new Point (1.0,2.0,3.0); 
		Point P1 Point = new new (0.0,0.0,0.0); 
		System.out.println (p.getDistance (P1)); //14.0 
		
		p.setX (5.0); 
		System.out.println (p.getDistance (new new Point (1.0,1.0,1.0 ))); //21.0 
	} 
}

 

Guess you like

Origin www.cnblogs.com/lsswudi/p/11222853.html