Question: can you make these two codes work together on the same page? public class Triangle extends GeometricObject { private double side1; private double side2; private

can you make these two codes work together on the same page?
public class Triangle extends GeometricObject {
private double side1;
private double side2;
private double side3;
/** Construct default Triangle object */
Triangle() {
side1 = side2 = side3 = 1.0;
}
/** Construct a triangle with specified side1, side2 and side3 */
Triangle(double side1, double side2, double side3) {
this.side1 = side1;
this.side2 = side2;
this.side3 = side3;
}
/** Return side1 */
public double getSide1() {
return side1;
}
/** Return side2 */
public double getSide2() {
return side2;
}
/** Return side3 */
public double getSide3() {
return side3;
}
/** Return area of this triangle */
public double getArea() {
double s = (side1 + side2 + side3) / 2;
return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
}
/** Return perimeter of this triangle */
public double getPerimeter() {
return side1 + side2 + side3;
}
/** Return a string description for the triangle */
public String toString() {
return "Triangle: side1 = " + side1 + " side2 = " + side2 + " side3 = " + side3;
}
}
*****************************************
import java.util.Scanner;
abstract class GeometricObject
{
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** 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.Date getDateCreated()
{
return dateCreated;
}
@Override
public String toString() {
return "created on " + dateCreated + " color: " + color +
" and filled: " + filled;
}
/** Abstract method getArea */
public abstract double getArea();
/** Abstract method getPerimeter */
public abstract double getPerimeter();
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!