Question: hi, need help for this project: DONT FORGOT TO DO: you should use arrays in the programme. And helper methods should be private, not public.

hi, need help for this project:

DONT FORGOT TO DO: you should use arrays in the programme. And helper methods should be private, not public. Explain the reason why. You may put your answer into the block comments at the top of the CircleSet class comments: extra credits Add code to your project to draw all circles on a DrawingPanel. The DrawingPanel should be 300 x 300.

Circles

You have been hired by a company to write a program that will read in a set of data about circles from a text file and produce certain information about the data set.

Concepts

Arrays of Objects

File input

Input Data Files and storage A circle can be defined by its center point (x, y) and its radius.

The text files your code will read from have the following pattern: they start with one integer, followed by a sequence of two number sets on two lines. The very first integer is how many sets are in the file. On the subsequent line, the first two numbers are the x and y coordinates of its center and the next number is the circle radius. These three values are integers. The last 3 numbers are the Red value, Green value , and Bluevalue of the color of the circle. These will be integers from 0 to 255. No commas, no parentheses, just values separated by space (whitespace). You program does not have to be responsible for files that do not match this format (in other words, if the end user gives you a filename with bad data and the program crashes, that's ok). You can create any text file you want for testing (use a program like Notepad or any other basic text editor). Here are some files I've created for you to use: circleData1.txthi, need help for this project: DONT FORGOT TOhi, need help for this project: DONT FORGOT TO and circleData2.txthi, need help for this project: DONT FORGOT TOhi, need help for this project: DONT FORGOT TO

You can copy and paste this data into a text file as a simple test case:

4

0 100 200

150 255 255

-50 -50 150

5 10 100

300 400 250

100 250 0

-200 150 100

200 200 200

Make sure to look at and run the sample programs on the website that illustrate reading data from a file (see week 5). Code Specification

Implement the class specifications below. To get full credit, your program's public interface must match these descriptions exactly. No other methods need to be implemented, although you might want to write a static test method in CircleSet as a way to verify that your program works correctly.

class Circle
You decide your instance variables

+ Circle (int x, int y, int r, Color c) -- initialize this Circle object with the given coordinates for its center, radius, and color. Throws an IllegalArgumentException for radius

+ Point getCenter() -- returns the center of this Circle. You may use the Point class from week 4 or write your own. + int getRadius() -- returns the radius of this Circle

+ Color getColor() -- returns the Color of this Circle + String toString() -- returns a String representation of this Circle + double area() -- returns the area of this Circle + double perimeter() -- returns the perimeter of this Circle + boolean overlaps(Circle other) -- returns true if this Circle and the other Circle overlap, or their boundaries touch, false if not + double distance(Circle other) -- returns the distance from this Circle's center to the other Circle's center. + double brightness() -- returns the brightness of this Circle. The formula for brightness =

+ void setCenter(int x, int y) -- change the center of this Circle + void setRadius (int r) -- change the radius of this Circle. Throws an IllegalArgumentException for invalid radius + void setColor(Color c) -- change the color of this Circle

In another file, implement the class specification below. To get full credit, your program must include each of the following methods, and the method signatures (name, parameter list and return type) must match these descriptionsexactly.

class CircleSet
You must use an array. The rest of the decisions here are yours.

+ public CircleSet(String fileName) throws FileNotFoundException -- initializes a CircleSet object using the data from the specified file. Throw IllegalStateException if the file has fewer than 2 Circles

+ int getCount() -- returns the number of Circlein 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 Circle, 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 smallestArea() -- returns the Circle with the smallest area. If 2 or more Circles have the same area, return the earliest one stored in the file.

+ Circle[] furthest() -- returns an array with the 2 Circles from this CircleSet whose centers are the farthest distance from each other.

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.

There is no need for any static methods at all. This program can be tested completely in BlueJ. However, if you prefer, you can supply a way to formally start the program:

public static void main(String[] args) {

CircleSet cs = new CircleSet();

}

or, you may find it convenient to create a test method:

public static void test() {

CircleSet cs = new CircleSet();

cs.getCount();

// etc.

}

Documentation and Style

Make sure to write complete Javadoc comments for each class and each public method.

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 (0.5 point)

Under the suggestions, I specify that helper methods should be private, not public. Explain the reason why. You may 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.5 points) Add code to your project to draw all circles on a DrawingPanel. The DrawingPanel should be 300 x 300.

Rubric

Some Rubric

Some Rubric

Criteria Ratings Pts This criterion is linked to a Learning OutcomeProgram execution and design 15.0 pts This criterion is linked to a Learning OutcomeDocumentation and Style 5.0 pts This criterion is linked to a Learning OutcomeExtra Credit 0.0 pts This criterion is linked to a Learning OutcomeLate 0.0 pts Total Points: 20.0

Previous

circle data2:

100 -149 -127 193 100 7 50 -129 -59 184 112 242 32 -86 -18 31 253 179 248 -133 -171 173 2 95 2 -156 -27 253 188 80 160 -27 -40 120 190 132 53 -117 -54 275 188 67 142 -57 -51 87 66 225 182 -165 -102 9 176 204 230 -90 -25 225 21 202 29 -42 -21 119 235 42 102 -118 -113 168 171 217 177 -168 -22 214 126 86 185 -36 -113 50 103 254 111 -116 -72 290 97 101 0 -83 -177 205 170 62 106 -164 -107 235 97 216 205 -199 -33 126 51 193 130 -60 -126 146 130 89 105 -18 -7 121 154 247 147 -113 -137 283 109 13 213 -74 -16 12 108 80 174 -62 -137 292 117 200 187 -193 -182 184 182 102 148 -118 -118 218 186 9 113 -175 -115 193 161 226 184 -165 -42 267 58 55 232 -136 -35 127 225 207 240 -27 -176 132 62 98 159 -182 -58 7 62 200 251 -74 -181 7 129 46 54 -1 -1 117 25 210 48 -120 -91 72 197 84 137 -65 -181 119 160 208 232 -79 -134 108 218 125 232 -109 -191 269 137 42 240 -149 -146 267 180 117 131 -61 -151 282 147 157 46 -127 -149 21 118 31 238 -186 -133 26 35 47 163 -72 -33 222 73 151 137 -94 -25 261 20 89 240 -50 -71 31 183 217 205 -44 -54 19 75 110 4 -153 -71 191 62 79 7 -27 -136 48 246 246 142 -148 -62 165 2 25 177 -81 -114 262 141 64 20 -14 -25 183 233 12 37 -71 -59 225 29 185 6 -88 -8 120 244 250 117 -26 -35 118 237 112 149 -91 -12 88 159 71 128 -44 -89 58 236 160 72 -8 -187 170 39 196 12 -139 -104 107 96 99 253 -53 -153 202 221 0 11 -66 -113 210 27 195 194 -184 -130 202 84 129 177 -194 -146 90 203 46 87 -190 -71 119 215 101 88 -118 -111 11 200 220 243 -44 -4 141 104 214 128 -65 -6 141 255 183 94 -99 -153 127 236 243 95 -80 -166 236 2 207 126 -69 -115 281 223 160 194 -130 -69 226 21 216 244 -2 -172 219 186 214 188 -136 -68 5 251 157 67 -138 -140 284 191 82 73 -127 -129 277 84 145 148 -148 -165 213 114 167 24 -64 -35 129 179 146 150 -80 -118 190 39 76 58 -94 -181 287 95 179 167 -5 -98 203 183 109 113 -138 -61 53 142 30 173 -147 -175 212 76 8 160 -32 -62 178 196 29 128 -10 -99 4 190 255 132 -89 -36 57 253 50 246 -195 -152 227 57 163 184 -68 -136 61 208 98 206 -26 -98 150 69 77 2 -151 -80 82 49 204 34 -146 -5 144 152 68 178 -28 -75 184 191 65 165 -158 -89 225 22 180 192 -153 -195 202 202 237 6 -153 -96 5 143 37 212 -183 -51 110 234 95 200 -112 -136 80 3 206 227 -137 -42 108 99 82 97 -130 -69 116 89 86 113 -82 -70 288 241 152 133 -80 -132 151 254 213 130 -168 -29 283 212 29 161 -52 -28 131 217 146 253 -98 -77 229 221 249 75 

circle data 1;

15 -44 -29 30 155 204 73 -81 -171 152 194 199 198 -150 -79 167 187 183 87 -129 -53 172 42 67 174 -4 -36 182 113 144 206 -55 -177 247 106 100 0 -169 -75 92 20 125 93 -142 -48 95 232 186 244 -155 -110 185 246 116 215 -82 -160 297 36 27 167 -103 -195 92 14 60 244 -155 -89 155 74 205 191 -115 -123 168 145 161 168 -172 -75 86 63 147 25 -51 -74 181 151 71 116 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!