Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that shuffles an ArrayList of triangles. You must use the same Triangle class that you designed. Triangle class: Shape class that extends:

Write a program that shuffles an ArrayList of triangles. You must use the same Triangle class that you designed.

Triangle class:

image text in transcribed

Shape class that extends:

image text in transcribed

public class Triangle extends Shape { static int numofobjects; double siden, side2, side3; public Triangle( double sidel, double side2, double side3){ this.sidel = sidel; this.side2 = side2; this.side3 = side3; this.numo fobjects++; public static int getNumberOfObjects() { return Triangle.numo fObjects; public boolean isEquilateralTriangle() { return (this.sidel == this.side2) && (this.side2 == this.side3); public boolean isRightAngled Triangle() { double a = this.sidel; double b = this.side2; double c = this.side3; return (a*a == b*b + c*c) || (b*b == a*a + C*C) || (a*a == b*b + C*C); public double getArea(){ double a = this.sidel; double b = this.side2; double c = this.side3; double s = (a+b+c)/2; return Math.sqrt(S*(s-a)*(s-b)*(S-c)); public double getPerimeter() { double a = this.sidel; double b = this.side2; double c = this.side3; return a+b+c; public String toString(){ String str = "Triangle: "+ "sidel = "+this.side1+ ", " + "side2 = "+this.side2+ " " + "side3 = "+this.side3; return str; import java.lang. String; import java.util.Date; import java.lang.Object; public abstract class Shape extends Object { private final Date dateCreated = new Date(); protected Shape () { super(); public Date getDateCreated() { return this.dateCreated; @Override public String toString() { return "created on " + this.getDateCreated(); public abstract double getArea(); public abstract double getPerimeter(); public class Triangle extends Shape { static int numofobjects; double siden, side2, side3; public Triangle( double sidel, double side2, double side3){ this.sidel = sidel; this.side2 = side2; this.side3 = side3; this.numo fobjects++; public static int getNumberOfObjects() { return Triangle.numo fObjects; public boolean isEquilateralTriangle() { return (this.sidel == this.side2) && (this.side2 == this.side3); public boolean isRightAngled Triangle() { double a = this.sidel; double b = this.side2; double c = this.side3; return (a*a == b*b + c*c) || (b*b == a*a + C*C) || (a*a == b*b + C*C); public double getArea(){ double a = this.sidel; double b = this.side2; double c = this.side3; double s = (a+b+c)/2; return Math.sqrt(S*(s-a)*(s-b)*(S-c)); public double getPerimeter() { double a = this.sidel; double b = this.side2; double c = this.side3; return a+b+c; public String toString(){ String str = "Triangle: "+ "sidel = "+this.side1+ ", " + "side2 = "+this.side2+ " " + "side3 = "+this.side3; return str; import java.lang. String; import java.util.Date; import java.lang.Object; public abstract class Shape extends Object { private final Date dateCreated = new Date(); protected Shape () { super(); public Date getDateCreated() { return this.dateCreated; @Override public String toString() { return "created on " + this.getDateCreated(); public abstract double getArea(); public abstract double getPerimeter()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions