Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project: The Triangle Class Problem Description: Design a class named Triangle that extends GeometricObject. The class contains Three double data fields named side1, side2, and

Project: The Triangle Class

image text in transcribed

image text in transcribed

Problem Description: Design a class named Triangle that extends GeometricObject. The class contains Three double data fields named side1, side2, and side3 with default values 0.0 to denote three sides of the triangle A no-arg constructor that creates a default triangle with default values 1.0 to each of the three sides of the triangle A constructor that creates a triangle with the specified sidel, side2, and side3 . . The accessor methods for all three data fields . A method named getArea that returns the area of this triangle Hint: The area of a triangle could be computed using the following formula Let a,b,c be the lengths of the sides of a triangle. The area is given by Area = -/p(p-a)(p-b)(p-c) atb+c 2 where p is half the perimeter, or A method named getPerimeter that returns the perimeter of this triangle Hint: The Perimeter of a triangle is the sum of its sides . A method named toString) that returns a string description for the triangle. For the description returned by toString0 please see the sample run below. Sample Run The area is 0.49607837082461076 he perimeter is 3.5 Triangle: side! = 1.0 side-1.5 side3 = 1.0 created on Tue Oct 31 12:23:49 EDT 2017 color: yellow and filled: true public class Ass11TriangleClass -i public static void main (String[] args) Triangle triangle new Triangle (1, 1.5, 1); triangle.setColor ("yellow") triangle.setFilled (true); System.out.println ("The area is "+ triangle.getArea )) System.out.println("The perimeter is " + triangle.getPerimeter )) System.out.println (triangle.toString ))

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions