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

Problem Description: Design a class named ProblemSet_7_Triangle that extends Geo

ID: 3686191 • Letter: P

Question

Problem Description:

Design a class named ProblemSet_7_Triangle that extends GeometricObject. The class contains:

Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle.

A no-arg constructor that creates a default triangle.

A constructor that creates a triangle with the specified side1, side2, and side3.

The accessor methods for all three data fields.

A method named getArea() that returns the area of this triangle.

A method named getPerimeter() that returns the perimeter of this triangle.

A method named toString() that returns a string description for the triangle.

For the formula to compute the area of a triangle, see Exercise 2.19. The toString() method is implemented as follows:

return " ProblemSet_7_Triangle: side1 = " + side1 + " side2 = " + side2 +

" side3 = " + side3;

Draw the UML diagram that involves the classes ProblemSet_7_Triangle and GeometricObject. Implement the class. Write a test program that creates a ProblemSet_7_Triangle object with sides 1, 1.5, 1, color yellow and filled true, and displays the area, perimeter, color, and whether filled or not.

In Java the Triangle class should be name "ProblemSet_7_Triangle" and the Test class "ProblemSet_7_Test" if you'll be using separate class. If you include the two class in one class, call the class "ProblemSet_7"

Explanation / Answer

problem:

Design a class named ProblemSet_7_Triangle that extends GeometricObject. The class contains:

Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle.

A no-arg constructor that creates a default triangle.

A constructor that creates a triangle with the specified side1, side2, and side3.

The accessor methods for all three data fields.

A method named getArea() that returns the area of this triangle.

A method named getPerimeter() that returns the perimeter of this triangle.

A method named toString() that returns a string description for the triangle.

answer of this problem

program:

The GeometricObject

The Triangle program

The Testprogram.

UML DIAGRAMS TO EXPLAIN:

GeometricObject

-color: String
-filled: Boolean

+GeometricObject( )
+getColor ( ): String
+setColor ( color: String): void
+isFilled ( ): boolean
+setFilled (filled: Boolean): void
+toString ( ): String





Triangle

-side1: double
-side2: double
-side3: double

+Triangle( )
+Triangle( side1: double.side2: double,side3: double)
+getSide1( ): double
+getSide2( ): double
+getSide3( ): double
+setSide1( side1: double): void
+setSide2( side2: double): void
+setSide3( side3: double): void
+getArea( ):double
+getPerimeter( ): double
+toString ( ): String

or)



Also, you may want to verify to make sure your Booleans aren't supposed to be booleans. Also, you are missing a method in your Triangle class

-color: String                    -
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote