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

  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