It's for an assignment in my Intro to Comp Prog. so I'm definitely a beginner. Here's the assignment, I've been working on it for over a week, and it seems like it would be simple, but I cannot figure it out..
it's an assignment in DrJava, HERE IT IS:
Define a class named PhotoOps. Like you did in your last programming assignment, define the class with a String instance variable named _filename, and Picture instance variable named _picture. Define the constructor so that it accepts a String as an argument; the String passed in should be the name of a file in the
directory. Assign to _filename the result of combining the String �/eng/class/notes/cse113/intro-prog-java/mediasources/� with the constructor�s String parameter, using �+� to concatenate the two Strings.
(this is the part I can't really figure out) Now onto the new part of this programming assignment. In section 6.1 of the text, the authors explain how to compute the distance between two colors. They write, The Pixel class has an object method colorDistance(Color color) which returns the distance between the color in the current Pixel object and the passed color. Write a method which takes three arguments, a Color, targetColor, and an int, distance, and a second Color, newColor. Define the method so that it changes the color each Pixel in _picture that is within distance of the targetColor to newColor.
Now experiment with this method and the redMotorcycle.jpg picture to find a good value for the distance from java.awt.Color.RED which will change the color of the motorcycle�s red parts to java.awt.Color.WHITE. Write the value you think works best into a comment for the method you wrote.
HERE'S WHAT I HAVE SO FAR
AND THE ERRORS I'M GETTING
any help on how I can correct the errors, and complete the assignment would be EXTREMELY appreciated! thanks in advance
Originally posted by Henry Wong: Well, to directly answer you question, you implemented a method call colorDistance().... but I do have a question.
How did you implement it? You designed a method to call other methods, but you don't know what the other methods are supposed to do?
I can't imagine how it is possible to code something to use something else, and have no idea what that something else is supposed to do -- at minimum, you called it for a reason.
well I'm not sure that what I have already is correct in the first place..All I was given in the instructions is this: The Pixel class has an object method colorDistance(Color color) which returns the distance between the color in the current Pixel object and the passed color. Write a method which takes three arguments, a Color, targetColor, and an int, distance, and a second Color, newColor. Define the method so that it changes the color each Pixel in _picture that is within distance of the targetColor to newColor.
What I have done so far I have pieced together from previous assignments or examples, so I could have some things in the code that don't belong there in the first place.