Design a class named triangle

Assignment Help JAVA Programming
Reference no: EM131590833

This the problem:

Design a class named Triangle that extends GeometricObject:

import java.util.Scanner;

abstract class GeometricObject {
private String color = "white";
private boolean filled;
private java.util.DatedateCreated;

/** Construct a default geometric object */
protected GeometricObject() {
}

/** Construct a geometric object with color and filled value */
protected GeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}

/** Return color */
public String getColor() {
return color;
}

/** Set a new color */
public void setColor(String color) {
this.color = color;
}

/** Return filled. Since filled is boolean ,
* the get method is named isFilled */
public boolean isFilled() {
return filled;
}

/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}

/** Get dateCreated */
public java.util.DategetDateCreated() {
return dateCreated;
}

@Override
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color +
" and filled: " + filled;
}

/** Abstract method getArea */
public abstract double getArea();

/** Abstract method getPerimeter */
public abstract double getPerimeter();
}

The Triangle class contains:

- Three double data fields named side1, side2, and side3
-
- A default constructor that creates a triangle with three sides of length 1.0

- A constructor that creates a triangle with specified values for side1, side2, and side3

- Accessor methods for all three data fields

- A method called getArea() that returns the area of a triangle

- A method named getPerimeter() that returns the perimeter of the triangle

- A method named toString() that returns the string description of the triangle in the following format: "Triangle: side1 = " + side1 + " side2 = " + side2 + " side3 = " + side3;

Test your Triangle class in a Drive program (in the same file) that prompts the user to enter the three sides of the triangle, the color, and whether or not the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties. Then, it should display the area, perimeter, color, and filled value .

Reference no: EM131590833

Questions Cloud

Discuss the optimizing database design : Many legacy systems require normalization. Identify at least two factors that should be considered in order to produce an optimal normalized set of tables.
What do you think the most important factors : What do you think the most important factors are to address in your program. Why. What is one strategy you would use
Write a report to your private investment company : Write a report to your private investment company and explain your analysis and your recommendations. Provide a rationale for your decision.
Explain the denormalization functionality : Having an adequate data model to serve specific business needs of an organization is important. Evaluate the need for denormalization within an organization.
Design a class named triangle : Design a class named Triangle that extends GeometricObject - Construct a geometric object with color and filled value - A default constructor
State the number of images : State the number of images formed when an object is between two plane mirror placed in parallel.
Determine the ideal number of clusters : The purpose of this assignment is to demonstrate steps performed in a K-Means Cluster analysis.
Illuminated by light of wavelength : A 3.0-cm-wide diffraction grating has 2500 slits. It is illuminated by light of wavelength 590 nm.
Where discount or premium appear in financial statements : Wie Company has been operating for just 2 years, Where should a discount or premium appear in the financial statements

Reviews

Write a Review

JAVA Programming Questions & Answers

  Sample papaer hello can you please help me to solve this

hello can you please help me to solve this sample paper and there is not submit date as this is for me but still i want

  A java program where the user designates

a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2

  Java class that represents your favorite musical instrument

Create your own Java class that represents your favorite musical instrument. Your musical instrument class should have at least 3 constants, 5 private data fields, getters and setters for each private data field, a to String() method, and three ad..

  What is the fourth number to be printed out

How many numbers will be printed out after executing the above algorithm - What is the fourth number to be printed out?

  Create a data set with 100 integer values.

Create a data set with 100 integer values. Create a program that uses the division method of hashing to store the data values into hash tables with table sizes of 7,,51 and 151. Use the linear probing method of collision resolution. Print out the ..

  Write a java program that simulates a small cpu vm

Design and implement a program to simulate the operation of the SIMMAC based - dumps the contents of all registers and memory and then prints an "End of Job" message.

  Write a program that bounces a blue ball inside a jpanel

Write a program that bounces a blue ball inside a JPanel. The ball should begin moving with a mousePressed event. When the ball hits the edge of the JPanel, it should bounce off the edge and continue in the opposite direction. The ball should be upda..

  What is the paintcomponent method how is it used in java

q1. what is the paintcomponent method? how is it used in java graphics? how does a program intentionally cause the

  Calculates the letter grade the student has earned

It then calculates the letter grade the student has earned, based on the average score of these assignments.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  A recently formed committee to deal with numerous

Scenario: You are a member of a recently formed committee to deal with numerous complaints against police and correction officers in your town and are asked to determine if there is merit to these allegations and develop a protocol to address the cur..

  Explain java-oriented microprocessors presented by sun

Research the latest Java-oriented microprocessors presented by Sun. In what ways are they optimized to implement Java programs?

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