Question
Please help me do the extra credit part. THANKS class name: CircleSet I leave this up to you to determine. You are limited to only
Please help me do the extra credit part. THANKS
class name: CircleSet |
|
+ public CircleSet(File source) throws FileNotFoundException -- initializes a CircleSet object using the data from the specified file. The data in the set should be in the same order as the data from the file. Throw an IllegalStateException if the file has fewer than 2 Circles + int getCount() -- returns the number of Circles in this set + double changingBrightness() -- this methods determines the overall change in brightness from one Circle to the next. Initially, overall change is 0. Going through the set looking at consecutive Circles, if there's an increase in brightness, increment the overall change by 1. If there's a decrease in brightness from one Circle to the next, decrement the overall change by 1. Return this overall change. + Circle[] smallLarge() -- returns an array of two Circles: the Circle with the smallest radius (index 0) and the Circle with the largest radius (index 1). If 2 or more Circles meet the same criteria, return the one stored in the set at the lowest index. + Circle[] getClosest() -- returns the two Circle objects whose centers are the closest. The Circles may or may not be next to each other in the array. If there are 2 or more pairs of Circles that are the closest, return the first pair found. + String toString() -- returns a String that represents the state of this object. The String should contain the toString() for each Circle object, separated by a new line character. |
Suggestions I hope by this point in the quarter you appreciate the benefit of working pieces of your solution one at a time. I recommend starting with the Circle class. Then, try to read in the data first (the constructor). Tackle one or two methods at a time. Test as you go. If it makes sense to decompose any of these methods, do so. However, the helper methods should all be private. Only these methods listed here should be part of the public interface.
Also, when dealing with the FileNotFoundException, every method that calls the CircleSet constructor also needs the throws clause in its method signature.
I encourage you to write static test methods to aid in testing your code. Documentation and Style
- Make sure to write complete Javadoc comments for each class and each public method.
- When a class reads from a file, it is important to document the format that file must follow so that clients know how to use the class correctly.
- Include sufficient internal, algorithm documentation.
- Use appropriate style (variable names, indenting, etc.) throughout the program.
Grading /15 Program works and contains the proper methods. Good overall design. /5 documentation, style
EXTRA CREDIT -- up to 2 points
public/private (1 point)
Under the suggestions, I specify that helper methods should be private, not public. Explain the reason why. Put your answer into the block comments at the top of the CircleSet class. Please make it obvious to me, such as a heading in the comments: EXTRA CREDIT.
Drawing the circles on the DrawingPanel (1 point) Add code to your project to draw on a DrawingPanel the Circles that are the result from a call to smallLarge().
As you know, Java puts the origin at the top left corner, with y increasing as you move down. Your task is to draw the circle as if on a mathematical rectangular coordinate system, with (0,0) in the center, and y coordinates increasing as you move up. For example, if the smallest circle has center (0,0) then the circle should be drawn in the center of the DrawingPanel. The panel should also draw and label the two axes. You may have to scale your axes so that both Circles show up, regardless of the coordinates. The image should be drawn as a postcondition of a call to smallLarge().
Please include the DrawingPanel.java class in your submission if your code uses it.
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