sphere2.java

来自「Java面向对象编程(随书配套源代码) 阐述了面向对象编程的思想」· Java 代码 · 共 42 行

JAVA
42
字号
package chapter7;
public class Sphere2 
{
    private static double PI =3.14;
	
	public double radius = 1;
	private double xCenter = 0;
	private double yCenter = 0;
	private double zCenter = 0;
	
	public Sphere2()
	{
		
	}
	public Sphere2(double x, double y,double z)
	{
		this.xCenter = x;
		this.yCenter = y;
		this.zCenter = z;
	}
	public Sphere2(double r,double x, double y,double z)
	{
		this(x,y,z);
		this.radius = r;
	}
	public Sphere2(final Sphere2 s)
	{
		this(s.radius,s.xCenter,s.yCenter,s.zCenter);
		s.radius =2;
	}
	
	
	public static void main(String[] args) 
	{
		Sphere2 globe = new Sphere2();		
		Sphere2 ball = new Sphere2(3,2,1);
		Sphere2 footBall = new Sphere2(4,2,3,0);
		Sphere2 footBall2 = new Sphere2(footBall);
		System.out.println(footBall.radius);
	}
}

⌨️ 快捷键说明

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