Java project.
Need help with this project, detail test case in particular.
Project 5: Lines Aplenty 1 Objective Now that we've created and used basic objects, we're moving forward to deeper object interactions (still "has a" relationships, though). We're adding in two new concepts as well: reading data from a file and storing objects in an array. This program has no user interface except for drawing panel output (in the extra credit portion) but will certainly have test methods that ensure all objects are behaving as intended. 2 Lines 2.1 Equations As you may remember from your math studies, lines can be represented by the equation: ymx + b where m represents the slope of the line and b represents the intercept (the place at which the line crosses the y axis). See this site for a review of the basic concepts 2.2 Intersections To find the point of intersection of two lines, substitute one line's mx+b value for the other equation'sy value, then solve for x. For example, find the intersection of lines y 4x-1 and yx+19: 4x-1=-x + 19 5x 20 You then find the y coordinate by substituting the now-known x: y-4x-1-) y-4(4)-1-) 15. So, the intersection of the two lines is at (4,15). See this site for a review of finding the intersection of two lines. You'll need to find a way to do this programmatically, translating the manual steps into code. 3 Brightness 3.1 Calculating Based on RGB Brightness is calculated based on the red, green, and blue components of a color. The equation for calculating it is as follows; note that the multiplier isn't squared, only the R, G, and B values are. 3.2 Increasing Brightness Sequence Looking at a sequence of brightness values, you'll be asked to find and return the longest sequence of increasing values. For example, given this sequence: 67.8, 91.3, 56.3, 87.3, 87.4, 90.4, 90.4, 55.0, the sequence that would be returned is the sequence of values shown in bold. In this project, you'll be asked to return an array of object references (not values) representing this sequence. 4 Input File 4.1 File The input file will contain the following elements, in order: On the first line, an integer indicating how many Lines are represented in the file. .One additional data line per Line, each having doubles representing slope and y intercept followed by three integers representing the red, green, and blue components of the line's color. The color elements are in the range of 0 to 255 Data elements are separated by spaces. . 4.2 Example Contents 2 4.0-2.0 240 56 33 1.0 5.0 0 200 175 The example file's contents are interpreted as follows: . There are two Lines represented in the file The first line's equation is y 4x-2 and has color R-240, G-56, and B-33. The second line's equation is y x+5 and has color R-0, G 200, B-175. 4.3 Notes Create the file in Notepad or in another simple text editor. Do not use programs that may write extra information into the file, e.g., Word or WordPad's .RTF files contain descriptive information that is problematic here. If you rely on text files for testing (expected), don't forget to include them in your submission. You are not responsible for bad data; if the file isn't created correctly and it blows up your program, that's okay for now. . 5 Classes 5.1 Classes to Create Here is the UML Class a" relationships. Create exactly these methods, with exactly the parameters and return types shown. the next page for other important notes Diagram for the classes you are to create and how they relate to each other via "has See Line LineSet tbd- you fill in this section) Point tbd-you fill in this section) Line Line(slope: Double, intercept:Double, -x: Double y:Double color: Color) LineSet(File lineFile) line Countt): Integer maxYIntercept(): Double min'Yinterceptt):Double maxintercept): Double +minXIntercept):Double getslopeo:Double getintercepto0 :Double .getontercepto : Double getColoro:Color +brightness0 Double toStringo: String Point Point(x : Double, y : Double) get : Double getYo:Double to Stringo: String avgBrightness():Double -setSlope(slope: Double) setintercept intercept: Double) setcolor(color: Color) toString): String -seo(nend: Double) +sefy(newY : Double) ghtSeq():Array of Line rawLines() findintersect(otherLine: Line) : Point 5.2 Notes 5.2.1 Line findintersect() throws an lIllegalArgumentException if the two lines are parallel. For the empty constructor, use slope 0.0, intercept-0.0, and Color.BLACK for defaults. 5.2.2 LineSet The constructor throws a FileNotFoundException if the file isn't found or an IllegalStateException if there are fewer than 2 lines in the set. Think carefully about the private member data you choose to store; just because you can compute it doesn't mean you need to store it. Consider that later we might add, delete, or manipulate individual lines, so your code would need to keep current all private data. Use a Scanner to read the text file; see the Hints section for more information. .For extra credit, implement the drawLines() method. Use the provided methods for finding the minimum and maximum X and Y intercepts, add some padding (say 20% on each side), then draw the lines using a DrawingPanel. Also, draw an X and Y axis for reference, though you don't need to label these in any way 5.2.3 Point You'll need a Point class that uses floating point values for x and y. The CSC142Point class in the course materials already provides that; I suggest adapting that for use here. There is no need to write additional test code for this unless you extend the functionality. 6 Code Implementation Follow the provided Course Style Guide. 7 Testing Create JUnit test classes for each production class that you write (ignore Point if you borrow it), and JUnit test methods for each production method. The testing here is significant and shouldn't be arn afterthought. I recommend writing the test methods early and adding to them as you code. .Don't forget to test all constructors as well as other methods .Don't forget to test preconditions and other code that is supposed to throw exceptions. To properly test LineSet's incrBrightSeq you'll need a variety of test files. Create files with different lengths of brightness sequences and files with the longest sequence at the start and the end of the file. This is important because we know as programmers we often create off-by-one errors; these can only be found through careful debugging and testing. Descriptive names for files will be helpful 8 Submitting Your Work Submit the entire project as a .jar file created by BlueJ. Be sure and specify "include source." BlueJ will automatically include test files that are in your project folder, or subfolders of it. 9 Hints I suggest building objects from the ground up, e.g., start with the Point class coding and testing, then move on to Line coding and testing, then finally LineSet. Incrementally develop your solution, building small additions on the solid foundation you've already laid Don't duplicate code; avoid this wherever possible. As an example, don't forget it's legal for one constructor to call another constructor; this is good practice and helps avoid duplication and the creation of extra code paths to test. . The algorithm for LineSet's incrBrightSeq function requires a good deal of thought before coding. I highly recommend doing work on paper to see how it should work, then writing pseudocode, then turning that pseudocode into Java code The text file is to be a tokenized file; that means that items can be separated by spaces, tabs, carriage returns, etc., and the code should work the same regardless of that fact. When you use a Scanner to read the file, the work of reading the next token is done for you automatically