Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement class Triangle that inherits form class GeometricObjects (provided to you with this assignment). Class Triangle has the following characteristics: Defines variables: side1,

Design and implement class Triangle that inherits form class GeometricObjects (provided to you with this assignment).

Class Triangle has the following characteristics:

Defines variables: side1, side2, and side3. Each is initialized with the value 1.0

Defines a default (non-argument) constructor to create a default triangle.

Defines a second constructor to allow the user to create triangles with user-specific side values.

Defines three access (get) methods, one for each variable, named getSide1(), getSide2(), and getSide3().

Defines method getArea() that computes and returns the area of a triangle object.

 s = (side1 + side2 + side3)/2 Area = Sqrt(s(s-side1)(s-side2)(s-side3)) 

Defines method getPerimeter() that computes and returns the perimeter of a triangle object.

 Perimeter = (side1 + side2 + side3) 

Defines method toString() that returns a meaningful description of a triangle object including its name, sides, area, and perimeter in this format:

Triangle: myTriangle Side 1: 4 Side 2: 5 Side 3: 6

Area: 9.921567416492215 Perimeter: 15

Write a test program named testTriangle to create couple triangle object and test all of the class methods on those objects. Add proper labels to your outputs.

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 Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago