Define a class named ComparableTriangle that extends Triangle and implements Comparable.
Draw the UML diagram for your classes and implement the compareTo method to compare the triangles on the basis of similarity.
Write a Driver class to determine if two instances of ComparableTriangle objects are similar.

Triangle Similarity: With the Triangle class we have already built, one that uses only side lengths, not angles, in its constructor, there is only one way we can check for similarity: side-side-side similarity. The definition of side-side-side similarity is:
If all the sides of a triangle are proportional to the corresponding sides of another triangle then the triangles are said to be similar.
in otherwords: (Triangle1 side1 / Triangle2 side 1) = (Triangle1 side2 / Triangle2 side2) = (Triangle1 side3 / Triangle2 side3)
Driver Run 1:
Enter three sides of the first Triangle
3 4 7
Enter three sides of the first Triangle
12 16 20

The Triangles are Not Similar

Driver Run 2:
Enter three sides of the first Triangle
2 3 3
Enter three sides of the first Triangle
4 6 6
The Triangles are Similar

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;

/*** Driver class ***/
public class Driver {

/*** GeometricObject class ***/
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) {

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats