Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java please a. Using UML notation, design a class called Triangle that will extend the GeometricObject class. The class contains: a. Three double data

in java please

image text in transcribedimage text in transcribedimage text in transcribed

a. Using UML notation, design a class called Triangle that will extend the GeometricObject class. The class contains: a. Three double data fields called side1, side2 and side3 to represent each side of a triangle with default value to 1.0 for each side. b. A no-argument constructor to create the default triangle. c. A constructor to create a Triangle object with specified value for each side. d. Access methods for each of the sides. e. A method getArea() to return the area of the triangle. Formula is shown below. f. A method getPerimeter() to return perimeter of the triangle. Perimeter is just the sum of each side. g. A static method tostring () to return string description of the triangle. Note that distance() method in part f to h is an example of Overload. Also, from now on, all methods are public unless specified to be private. In addition, all data fields will be private unless required to be public. We will use the Heron's formula to calculate area of any triangle (shown at right) with sides a,b and c The formula for area is shown: A=s(sa)(sb)(sc) And value of s is half the perimeter of the triangle. s=2a+b+c b. Implement your UML design in part (a) above in a Java class. The tostring() method should return this string: "Triangle : side1 = "+side 1+" side2 ="+ side 2+" side 3="+ side3 c. Write a test program that will prompt user to enter the three sides of the triangle, a color and a boolean value whether triangle is filled or not. Then create a Triangle object setting the sides and also the color and filled value. Finally display output of tostring() plus the area, the perimeter, the color and whether it is filled or not (boolean value)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

L02 Review the main sources of genetic diversity.

Answered: 1 week ago

Question

Draw a labelled diagram of the Dicot stem.

Answered: 1 week ago