You are to create a new child class to model an equilateral


Assignment

In this assignment you will create a new child class and new driver program. Please review that example before continuing with this assignment. You should fully understand the shape program above.

You are to create a new child class to model an equilateral triangle. An equilateral triangle is a triangle where the length of all three sides is the same.

Like all shapes, our equilateral triangle will have a color and name. Specific to the equilateral triangle will be the length of its side (remember all three sides are of the same length).

Using the shape class above as a parent write a child class called EquilateralTriangle that contains:

An attribute of side length

Methods that set and get the side length

A method to compute the perimeter of the triangle ( 3 * side)

A method to compute the area of the triangle. The formula is as follows:

Area = side2 * √(3 )/4

A toString method to return a string containing all information stored about the triangle

An appropriate constructor

Be sure to extend the Shape class so that the new child class can inherit all the attributes and methods contained in Shape

In another file create a driver program that will create two equilateral triangle objects, print the attributes of those objects (invoke the toString methods) and then print both the area and perimeter of those objects.

Please name your programs "FirstnameLastnameProgram1.java" and "EquilateralTriangle.java"

Solution Preview :

Prepared by a verified Expert
JAVA Programming: You are to create a new child class to model an equilateral
Reference No:- TGS01693375

Now Priced at $40 (50% Discount)

Recommended (93%)

Rated (4.5/5)