У меня есть несколько геометрий, которые простираются от класса формы, подобно следующему: < /p>
public class ExtendedLine extends Line {
private String attribute;
// more attributes and methods
}
< /code>
public class ExtendedCircle extends Circle {
private String attribute;
// more attributes and methods
}
< /code>
Now, to access all geometries at once, I defined a super class which extends Shape and contains all attributes and methods which the ExtendedLine and ExtendedCircle have in common. This saves me a lot of redundant code.
public class Geometry extends Shape {
private String attribute;
// more attributes and methods
}
< /code>
public class ExtendedLine extends Geometry {
}
< /code>
public class ExtendedCircle extends Geometry {
}
< /code>
Is it allowed / good practice to extend the Shape class?
Подробнее здесь: https://stackoverflow.com/questions/732 ... hape-class