[go: up one dir, main page]

0% found this document useful (0 votes)
24 views5 pages

Quadrilateral Class Hierarchy in Java

The document outlines a Java project structure for a quadrilateral class hierarchy, centered around an abstract superclass 'Quadrilateral' that defines common attributes and methods. Subclasses such as Rectangle, Rhombus, and Trapezoid implement specific behaviors, particularly in area calculation, while inheritance and method overriding reduce code duplication and enhance flexibility. Manual testing is conducted to validate the correct implementation of inherited and overridden methods for perimeter and area calculations across the subclasses.

Uploaded by

camlio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

Quadrilateral Class Hierarchy in Java

The document outlines a Java project structure for a quadrilateral class hierarchy, centered around an abstract superclass 'Quadrilateral' that defines common attributes and methods. Subclasses such as Rectangle, Rhombus, and Trapezoid implement specific behaviors, particularly in area calculation, while inheritance and method overriding reduce code duplication and enhance flexibility. Manual testing is conducted to validate the correct implementation of inherited and overridden methods for perimeter and area calculations across the subclasses.

Uploaded by

camlio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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.

You might also like