Question
//Circle Class import java.util.*; public class Circle { private int x; private int y; private int radius; public Circle1(){ this(0,0,0); } public Circle1(int x, int
//Circle Class
import java.util.*; public class Circle { private int x; private int y; private int radius; public Circle1(){ this(0,0,0); } public Circle1(int x, int y, int radius){ this.x=x; this.y=y; this.radius=radius; } public int getX(){ return x; } public int getY(){ return y; } public int getRadius(){ return radius; } public String toString(){ return "Center: (" +x+","+y+") Radius: " + radius; } }
1. Given the Circle class above, add a compareTo method to the above class and write a client class that calls a method that implements the modified version of insertion sort algorithm that sorts an array of Circle.
2. Declare an interface called Incrementable which represents items that store an integer that can be incremented in some way. The interface has a method called increment that increments the value and a method called getValue that returns the value. Once you have written the interface, write two classes called SequentialIncrementer and RandomIncrementer that implement the interface. The SequentialIncrementer begins its value at 0 and increases it by 1 each time it is incremented. The RandomIncrementer begins its value at random integer and changes it to a new random integer each time it is incremented.
Write a client class that creates objects of the two classes and prints out the values before calling the increment method and after calling the method. Call the increment method multiple times and print out the values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started