Description of this paper

java program

Description

solution


Question

public class Shape;private String name;private String color;public Shape(String n, String c);name=n;color=c;//mutator methods;public void setName(String n);name=n;public void setColor(String c);color=c;//accessor methods;public String getName();return name;public String getColor();return color;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

 

Paper#66432 | Written in 18-Jul-2015

Price : $22
SiteLock