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 an array of five employee objects

Create an array of five Employee objects. Prompt the user to enter data for each Employee. Do not allow duplicate ID numbers to be entered.

  Create a virtual directory

Create a Web archive file and attach to this assignment. Do not copy (cut and paste) any example code, create your own code and use the examples as a guide.

  Compute the fifties and the remaining amount

Prompt the user for a string input value for the amount in dollars and store it in a variable named input and convert the string to an integer and store it in the variable named amount.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Create a class that calls that parse method

Use the Java API documentation to examine the SimpleDateFormat class and find the exception thrown by its parse() method. Create a class that calls that parse() method.

  Writing a program to have it generate random words

How would I go about writing a program to have it generate random words with a letter missing for a child to guess? Maybe it would have three letters, then four, next five, and so on until maybe 10 letters. Please keep in mind that I'd like it to wor..

  1 write a recursive instance method called

1 write a recursive instance method called countconnectedpipesint row int col. the method must not contain any loops

  Program obtaining the new scriptdownload and save the

program obtaining the new scriptdownload and save the attached comment cgi mailer script form-mail2.pl to your servers

  Implement one class called parking meter

Implement one class called parking meter, that is a simple model of a coin operated parking meter

  Create an array of integers at random

create an array of integers at random with a range of 0 through 1000 in Java... any hints?

  Write a thread function to initialize 2d array

write a thread function to initialize int 2D array x (NxN) so that each thread initializes its portion with i+j in each slot. Note that i and j relate to the entire array.

  Add event handling to the button find out the value the

make a windows program in java that has a labeled text field for the price of a meal. there are different discounts for

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