Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make the following two classes (you can add other methods, Constructors, and instance variables, if necessary ): 1.) class Triangle Instance Variables: height, base Methods:

Make the following two classes (you can add other methods, Constructors, and instance variables, if necessary):

1.) class Triangle

Instance Variables: height, base

Methods: setHeight(), setBase(),getHeight(), getBase(), displayArea().

2.) class Circle

Instance Variables: radius

Methods: setRadius(),getRadius(),displayArea().

Use the following Tester class (you are NOT allowed to add any code to the Tester class)

public class Tester {

public static void main(String[] args) {

Triangle myTriangle = new Triangle();

Triangle yourTriangle = new Triangle();

Circle myCircle = new Circle(6);

Circle yourCircle = new Circle(6);

myTriangle.setHeight(8);

myTriangle.setBase(4.7);

myTriangle.displayArea();

System.out.println(myTriangle == yourTriangle);

System.out.println(myCircle == yourCircle);

System.out.println(myTriangle.equals(yourTriangle));

System.out.println(myCircle.equals(yourCircle));

System.out.println(myTriangle.toString());

System.out.println(Circle.radius);

System.out.println(Circle.displayArea(5));

System.out.println(yourCircle.displayArea());

}

}

The output should be:

0.0

false

false

false

true

This is a triangle

6.0

78.5

113.097

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

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago