Question
Triangle Class as a Subclass of GeometricObject Submit Triangle.java, GeometricObject.java, Lab4.jar, screen shots of results, and this word file (completed version) Problem Description: Design, implement,
Triangle Class as a Subclass of GeometricObject
Submit Triangle.java, GeometricObject.java, Lab4.jar, screen shots of results, and this word file (completed version)
Problem Description:
Design, implement, and test Triangle class that extends GeometricObject in text book.
The Triangle class contains:
- Three double data fields named side1, side2, and side3 (default values 1.0) to denote three sides of the triangle.
- A default constructor (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 isEquilateral() that returns true if the triangle is equilateral.
- A method named isIsosceles() that returns true if the triangle is isosceles.
- A method named toString() that returns a string description for the triangle.
For the formula to compute the area of a triangle, see Exercise 5.19. The toString() method is implemented as follows:
return "Triangle: side1 = " + side1 + " side2 = " + side2 +
" side3 = " + side3;
- Design. Draw the UML class diagram for Triangle and GeometricObject classes with class inheritance. Implement the Triangle class. Write a test program that creates a Triangle object with sides 1, 1.5, 1, color yellow and filled true, and displays the area, perimeter, color, and whether filled or not.
|
|
Complete the UML class diagram here
- Implement Triangle class as a subclass of GeometricObject class.
Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)
- Test your program. Explain how did you test your program and copy your test code here.
- Running result: Copying the running result here.
Remark:
A triangle in which all three sides have equal lengths is called an equilateral
triangle and a triangle in which two sides have equal lengths is called isosceles.
Don't forget to answer the sub-questions :)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started