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

📄 point3d.java

📁 java入门级程序 类及继承
💻 JAVA
字号:
//package tree.point3d;
import tree.point2d.Point2D;

import java.math.*;


public class Point3D extends Point2D
{
	private int z;
	public Point3D ( int x, int y, int z)
	{
		this.x=x;
		this.y=y;
		this.z=z;
	}
	public Point3D ( Point2D p, int z )
	{
		x=p.x;
		y=p.y;
		this.z= z;
	}
	public void offset ( int a, int b, int c)
	{
		x+=a;
		y+=b;
		z+=c;
		//return true;
	}
	public double dis ( Point3D p )
	{
		double d;
		d = (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)+(z-p.z)*(z-p.z);
		d  = Math.sqrt(d);
		return d;
	}
	public static void main ( String args[] )
	{
		Point2D p2d1,p2d2;
		p2d1=new Point2D( 0, 0 );
		p2d2 = new Point2D( 1, 1 );
		System.out.println( p2d1.dis ( p2d2 ) );
		Point3D p3d1,p3d2;
		p3d1 = new Point3D( 0, 0, 0);
		p3d2 = new Point3D( p2d2, 1 );
		System.out.println(p3d1.dis(p3d2));

	}
};

⌨️ 快捷键说明

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