Create a new child class and new driver program

Assignment Help JAVA Programming
Reference no: EM13804796

Java program-

Pin It

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.

Reference no: EM13804796

Questions Cloud

Returns the value of the arithmetic sum up to n : Write and test the following function that returns the value of the arithmetic sum up to neg. SumUpto(5) = 5+4+3+2+1 =15int SumUpto(int)
Description of the terrorist activity in the selected areas : The CEO has asked you to define the psychological perception of risk of employees who work in the company's high-risk areas at the annual board meeting. The CEO feels that by defining the perception of risk
Design a program in pseudocode : Design a program in pseudocode that solves this problem. You are required to generate only the pseudocode - No charting or analysis section is required, but you may have to incorporate the bubble sort algorithm to determine the minimum and maximum..
Unattractive sides of many of novella supporting characters : In The Pearl, John Steinbeck does not shy away from showing readers unattractive sides of many of the novella's supporting characters.
Create a new child class and new driver program : 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
Determine if the problem is either a test of hypothesis a co : Directions: Read the following problem. In your drop box submission, please include the following information: a. Determine if the problem is either a test of hypothesis, a confidence interval or something else and specify the 'key words' found in th..
About global social issue : global social issue
Analyze the major points of george washington''s : For this assignment, you will analyze the major points of George Washington's "Farewell Address" and write a 3-page analysis, considering contemporary government and including differing points of view.
Create a new project in bluej by clicking on the menu option : Create a new project in BlueJ by clicking on the menu option Project > New project. This will create a folder with the project name (see below). All BlueJ project-related files for this project will be stored in this folder. Create new classes by ..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd