QUADRILATERAL CLASS
HIERARCHY IN JAVA
CRISTHIAN CAMILO PEÑA ÁLVAREZ
CLASS DIAGRAM
PROJECT STRUCTURE
• The project is organized in a package called Cuadrilat that contains:
• Cuadrilateral.java :
• centralizes common attributes and methods for
quadrilaterals. The abstract class ensures the
implementation of key methods and avoids direct
instantiations. In addition, inheritance simplifies
design by reducing code duplication, while
overriding allows behavior to be tailored to each
subclass.
• Subclasses:
• Includes specific implementations such as
Deltoid, Rectangle, Parallelogram, Rhombus,
Rhomboid, Trapezoid, Trapezium, and Isoceles
Trapezium.
• Main.java:
• The main class for testing and validating
program behavior.
SUPERCLASS QUADRILATERAL
• Base of the hierarchy:
• The abstract Quadrilateral class defines the common
attributes (sideAD, sideBA, sideCB, sideDC), which represent
the sides of any quadrilateral, and a constructor to initialize
them.
• Inherited methods:
• The getter and setter methods allow you to access and
modify the sides, while calculatePerimeter() calculates the
perimeter by adding the four sides together. These methods
are directly inherited by subclasses.
• Overridden Methods:
• The abstract method calculateArea() forces each subclass to
override it with the appropriate formula, such as base ×
• Inheritance reduces code duplication by height in parallelograms or diagonal multiplication in
centralizing common logic in a superclass, rhombuses.
allowing subclasses to implement only the
specific features that differentiate them.
MANUAL TESTING • The test cases in the main class demonstrate how each
Quadrilateral subclass correctly implements the inherited
and overridden methods, the tests validate the following:
• Perimeter Calculation:
• Method inherited from the superclass,
used directly in all subclasses.
• Area calculation:
• Method superscribed in each subclass,
adapted to its specific formula (for
example, base × height in parallelograms
or (diagonal 1 × diagonal 2) ÷ 2 in
deltoids).
• This confirms the correct use of inheritance and
• Method overriding allows each subclass to
polymorphism, in addition to guaranteeing accurate
customize its behavior, flexibly adapting to the
results in the calculations of each geometric figure.
specific requirements of its design without
altering the structure of the superclass.