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

  Create your own date class

You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program:

  Create a website

The preplanning design consists of a document that defines the element specifically requested by the client and indicates where these features will be located on the Website

  Calculate the largest divide by the smallest number

Please also calculate the largest divide by the smallest number provide the quotient and remainder and also put the information as a string on the applet. All the numbers will presented in two decimal places.

  Implement a set as a new class that is derived

A set is like a bag, except that a set does not allow multiple copies of any element. If you try to insert a new copy of an item that is already present in a set, then the set simply remains unchanged.

  Create a new android application project

You have been hired to create a mobile application for Healthy Life, a local organic bakery and grocery store. The main screen should state the name of the person who owns the phone. Create a new Android Application Project

  Implement the link list using java programming concepts

Modify the class LinkedList by adding to it the following methods. The appropriate error message should be generated if an invalid condition occurs.

  Write a script that prints out the full pathnames

Write a script that prints out the full pathnames of your files that are over a specified size.  The size should beread as a command line argument to the script.

  In this assignment you will be asked to implement a card

in this assignment you will be asked to implement a card game. you will need to make several design decisions for your

  Write a java program in a netbeans project

Write a Java program in a NetBeans project

  Use a loop to allow a user to enter a series of numbers

Use a loop to allow a user to enter a series of numbers and then print out the series of numbers when the user is done. The user stops the lseries program by entering -1 (or any negative number).

  How large a value can be stored in an integer variable

Most programming languages have a built-in integer data type. Normally this representation has a fixed size, thus placing a limit on how large a value can be stored in an integer variable

  Prepare a java program to create a gui

Prepare a java program to create a GUI and show the picture of the zodiac. Be sure to include comments. The comment should describe the purpose of the program and the data to be entered.

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