Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from the main method and print their areas and perimeters. Polygon {abstract} # color: String #...


Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from the main method and print their areas and perimeters.


Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from the<br>main method and print their areas and perimeters.<br>Polygon<br>{abstract}<br># color: String<br># numberOfSides: int<br>+ Shape()<br>+ Shape(color:String, numberOfSides:int)<br>+ getColor(): String<br>+ setColor(color:String): void<br>+ getNumberOfSides(): int<br>+ setNumberOfSides(sides:int):<br>+abstract getArea(): double<br>+abstract getPerimeter(): double<br>Triangle<br>|- sides: int[ ]<br>+ Triangle(color:String, numberOfSides:int)<br>+ addSide(index:int, sideValue: int): void<br>+ getSide(index:int): int<br>+ getArea(): double<br>+ getPerimeter(): double<br>

Extracted text: Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from the main method and print their areas and perimeters. Polygon {abstract} # color: String # numberOfSides: int + Shape() + Shape(color:String, numberOfSides:int) + getColor(): String + setColor(color:String): void + getNumberOfSides(): int + setNumberOfSides(sides:int): +abstract getArea(): double +abstract getPerimeter(): double Triangle |- sides: int[ ] + Triangle(color:String, numberOfSides:int) + addSide(index:int, sideValue: int): void + getSide(index:int): int + getArea(): double + getPerimeter(): double

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here