Activity
Activity
*;
public class RunQuad {
if(shape.equalsIgnoreCase("R")){
Rectangle rec = new Rectangle();
System.out.println("____________________________");
System.out.println("A rectangle: ");
rec.showDescription();
}
else if(shape.equalsIgnoreCase("S")){
Square sq = new Square();
System.out.println("____________________________");
System.out.println("A square: ");
sq.showDescription();
}
else if(shape.equalsIgnoreCase("P")){
Parallelogram par = new Parallelogram();
System.out.println("____________________________");
System.out.println("A parallelogram:");
par.showDescription();
}
else if(shape.equalsIgnoreCase("H")){
Rhombus rhom = new Rhombus();
System.out.println("____________________________");
System.out.println("A rhombus: ");
rhom.showDescription();
}
else if(shape.equalsIgnoreCase("T")){
Trapezoid trap = new Trapezoid();
System.out.println("____________________________");
System.out.println("A trapezoid: ");
trap.showDescription();
}
else{
System.out.println("Invalid Input!!");
}
}
}
class Quadrilateral {
public void showDescription() {
System.out.println("- is quadrilateral");
}
}
class Rectangle extends Quadrilateral {
public void showDescription() {
super.showDescription();
System.out.println("- has 4 right angles");
}
}