Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help finishing up this code, I dont know what to put for the public boolean equals(Circle guest) method ______________________________________________ public class Circle {

I need help finishing up this code, I dont know what to put for the public boolean equals(Circle guest) method

______________________________________________

public class Circle {

private double radius;

private double getRadius()

{

return radius;

}

private void setRadius(double radius)

{

if (radius > 0)

this.radius = radius;

}

public void resize(double newRadius)

{

setRadius(newRadius);

}

public Circle clone()

{

Circle clone = new Circle();

clone.setRadius(getRadius());

return clone;

}

public boolean equals(Circle guest)

{

//HELP

}

public void print()

{

System.out.println("radius = " + getRadius());

}

}

_________________________________________________________-

import java.util.Scanner;

public class CircleDriver

{

public static void main(String[] args)

{

Scanner stdIn = new Scanner(System.in);

Circle big = new Circle();

Circle small = new Circle();

System.out.println("");

System.out.print("Big : ");

big.print();

System.out.println("");

System.out.print("Small : ");

small.print();

System.out.println(" ");

double bigRadius;

System.out.print("Enter the radius of a big circle : ");

bigRadius = stdIn.nextDouble();

big.resize(bigRadius);

double smallRadius;

System.out.print("Enter the radius of small circle : ");

smallRadius = stdIn.nextDouble();

small.resize(smallRadius);

System.out.println("");

System.out.print("Big : ");

big.print();

System.out.println("");

System.out.print("Small : ");

small.print();

System.out.println("");

if (big.equals(small))

System.out.println(" big equals small ");

else

System.out.println(" big does not equals small ");

System.out.println("");

Circle bigCopy = big.clone();

System.out.print("BigCopy : ");

bigCopy.print();

System.out.println("");

if (bigCopy.equals(big))

System.out.println(" bigCopy equals big ");

else

System.out.println(" bigCopy does not equals big ");

System.out.println("");

}

}

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

Students also viewed these Databases questions

Question

Can EM waves travel through a perfect vacuum? Can sound waves?

Answered: 1 week ago