Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

progranating Name your 6 files for PA#5: : P5.java P5RegHexagon.java P5Rectangle

ID: 3860035 • Letter: P

Question

progranating Name your 6 files for PA#5: : P5.java P5RegHexagon.java P5Rectangle.java P5Polygon.java P 5RegHexPrism.java P5Cuboid.java DUE: Tuesday, July 25, 2017 6am P5Polygon data:side abstract P5Rectangle data:height P5RegHexagon P5RegHexPrism data:height PSCuboid data:length You wil1 write a program to calculate the area P5RegHexPrism and volume of a P5RegHexPrism, ares a P5Cuboid and volume of a P5Cuboid, using classes e a program to calculate the area of a P5RegHexagon, surface area of a risn, area of a P5Rectangle, surface area of , using classes and an inheritance hierarchy. PA# 5 consists of 6 P5RegHexagon.j the grader pr be named exactly as specified n of 6 public classes in six separate files: P5.java PSPolygon.java program to collect your entire PAiS source files, these file nanes MUST aradeava PRegHexPrism.java PSRectangle.java, P5cuboid. Java) n order o P5Polygon: P5RegHexagon: Subclass of P5Polygon P5RegHexPrism: Sbclass of P5RegHexagon P5Rectangle: Subclass of P5Polygon P5Cuboid: Abstract superclass of P5RegHexagon and PSRectangle Subclass of P5Rectangle application (driver program) NOTE: NO error checking of input data is required with corresponding error messages because data is type "double" checked. Grader input will include appropriate positive numeric values In production programming, ALL input is error PsRectangle.java and P5Cuboid.java refer to "OOP" handout and hint P5RegHexagon and P5RegHexPrism. The height to1.1 tostring() may look like: "return ("get Name(): ,+ side.. x· s below or no argument P5Rectangle constructor initializ . tostring) may look like: "return ("getName ():It+ "return ("getName Oait side x height to 1.1. height ) P5Polygon.java. -No argument constructor, initialize side to one No argument constructor, initialize side to parameter - Format and return class name - Generates name of this class object and return as - Assign 1 dimension of 2-D polygon (side) * P5Polygon (double) toString() * getNane () a String . setDim(double) set Dim(double,double) setbinidouble, double, double)- Assign 3 dimensions of 3-D polygion (side, height, Lengtn perimeter () - Assign 2 dimensions of 3-D polygion (side, height) - Calculate perimeter of a polygon * area() " volume () Calculate area - Calculate volume of a polygion of a polygion a) At least one method is abstract (declaration b) Signature of tostring) is: public String tos aration only) tring ) finition is: return( this getclass 0.getHane): d) Wethods are declared abo ve so they may be accessed through P5Polygon array.

Explanation / Answer

P5Polygon.java

Abstract class P5Polygn

{

Double x,y,z;

P5Polygon()

{

X=y=z=-1;

}

P5Polygon(P5Polygon p)

{

X=p.x;

Y=p.y;

Z=p.z;

}

P5Ploygon(double s)

{

X=y=z=s;

}

Public double getName()

{

Return(this.getClass().getName() +”: “);

}

Public String toString()

{

Return (“getName():” );

}

Public double setDim(double x)

{

X=this.x;;

}

Public double setDim(double x,double y)

{

X=this.x;

Y=this.y;

}

Public double setDim(double x,double y,double z)

{

x=this.x;

y=this.y;

z=this.z;

}

Public double getPerimeter()

{

System.out.println(“perimeter:”);

Return 0;

}

Public double getArea()

{

System.out.println(“area of figure not defined:”);

Return 0;

}

Public double getVolume()

{

System.out.println(“Volume:”);

Return 0;

}

}

P5RegHexagon.java

Class P5RegHexagon extends P5Polygon

{

Double x;

P5RegHexagon(P5RegHexagon s)

{

Super(s);

X=s.x;

}

Public String toString()

{

Return (“getName():” +x );

}

Public double getArea()

{

Return (3*sqrt(3)/2)*(x*x)

}

Public void Perimeter()

{

Return 6*x;

}

Public void display()

{

getArea();

getPerimeter();

}

}

P5RegHexPrism.java

Class P5RegHexPrism extends P5RegHexagon

{

P5RegHexPrism(P5RegHexPrism ob)

{

Super(ob);

X=ob.x;

}

P5RegHexPrism(double s,double h)

{

Super(s,h);

X=x1;}

P5RegHexPrism(double s,double x1)

{

Super(s);

x1=-1;

}

}