geometricobject.java
来自「此源码为机械工业出版社出版的《Java语言程序设计》第三版所配套的书中所有源代码」· Java 代码 · 共 51 行
JAVA
51 行
// GeometricObject.java: The abstract GeometricObject class
public abstract class GeometricObject
{
protected String color;
protected double weight;
// Default construct
protected GeometricObject()
{
color = "white";
weight = 1.0;
}
// Construct a geometric object
protected GeometricObject(String color, double weight)
{
this.color = color;
this.weight = weight;
}
// Getter method for color
public String getColor()
{
return color;
}
// Setter method for color
public void setColor(String color)
{
this.color = color;
}
// Getter method for weight
public double getWeight()
{
return weight;
}
// Setter method for weight
public void setWeight(double weight)
{
this.weight = weight;
}
// Abstract method
public abstract double findArea();
// Abstract method
public abstract double findPerimeter();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?