Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA PROGRAM HELP: I need the following code. Write a class named Circle which represents a circle shape as described below: 1. Two attributes, color
JAVA PROGRAM HELP: I need the following code.
Write a class named Circle which represents a circle shape as described below: 1. Two attributes, color and radius. 2. A default constructor which initializes the attributes to red and 5, respectively. 3. A copy constructor. 4. A compareTo() method to determine if two Circle objects are the equal. Equality should be defined as the same color and the same radius. 5. A toString() method that returns the color and radius as a string. 6. A set function that allows the color of an object to be changed. 7. A set function that allows the radius of an object to be changed. Write a second class with a main function that declares two Circle objects: C1 and C2. Create a copy of C2 in a third object, C3 Compare the C1 and C2 and print the results. Change the color of C1. Compare C1 and C3 and print the results. Set the radius of C2 to 20. Print the results of toString() for C2Step 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