| ||||||||||
I want you to change the picture, in the same way that the method decreaseRed changes a picture. You can write a method that uses other methods, or you can write a method that does something entirely unique. Both are acceptable. My recommendation as the easiest thing to do is to copy-paste decreaseRed to the bottom of the class Picture, change its name, and change the innards to do something different. (Glad you're not dazed.) Mark Guzdial |
You turn in the Picture.java file with a new function added to the bottom and comments that include your name and what the function does. To receive full credit you must also name and comment the function properly. Look at the other picture manipulation functions in the file for examples. DO NOT turn in Picture.class as this is a compiled binary which I will be unable to grade. Student24 |
Make sure that you add the updated java-source dir to your classpath by using Edit->Preferences->Resource Locations->Extra Classpath if this doesn't work please post the exact error message you are getting. Student24 |
Yes on the course homepage 2nd link from the bottom. Student24 |
First make sure your changes are compiling successfully. If they do it is most likely that you made a mistake in your commenting. An unclosed comment near the top of the file would comment out every function in the picture class. However if you notice near the top of the file where it says "public class Picture extends SimplePicture" this means that class Picture will inherit all methods from class SimplePicture such as show(). Try testing all of the functions in Picture starting at the top of the file to see if you can locate any that are commented out. Student24 |
We'll be discussing inheritance, and creating a new method for Picture in class on Wednesday. Remember that the due date for the assignment has been pushed back until next Monday, so if you're reading along here wondering, "What are they TALKING about?!?" Don't worry. All will be explained Wednesday. Mark Guzdial |
Ooh! Neat trick! I'll have to try that. I've found the same thing, and wondered the same thing. I'll try the maximized front window, Mysterious Anonymous Answerer. Mark Guzdial |
Thanks, Charlie! Mark Guzdial |
attach/carmen, just like CS1315. Mark Guzdial |
I've uploaded jmusic to Installation Problems?, since the server seems to be down in Australia. Mark Guzdial |
It's perfectly okay to do both. I don't know why you're getting an out of memory error. Maybe you're making a picture inside a loop, so you're creating a few thousand of them? Maybe you're working with a 4 megapixel picture on a computer with only a little memory? Bring your code to me or Jonny to look at with you. Mark Guzdial |
We solved Yuka's problem – you have to edit THE Picture.java in java-sources. If you duplicate Picture.java, Java gets waaay confused. Mark Guzdial |
This usually happens when you either have an endless loop or you are creating large objects inside of a loop. However if all else fails, try closing and restarting. DrJava is also running using Java and may be the source of your memory issues. On my system I occasionally run out of memory if DrJava has been open for more than 2 days. One of the great things about Java is that it handles all memory management for you, unfortunatly it doesn't always manage perfectly which can add up after a few days. Student24 |
Your comment should go directly above the function that you have added (which should be the last function in the file) and be in the same style as the other comments in the file. Student24 |
Yup – that's exactly right! Make sure that your method is at the bottom of Picture.java, and that your comment (just above the method) gives your name, and your description of what you think is going on in your new method. Mark Guzdial |
Most likely you have pasted the new function outside of the class definition. Check that your new function code is inside the "{" started at "public class Picture" but outside of the "}" that define the last function in the class. In case that sounds confusing remember that portions of code inside of curly braces are the equivalent of indentation in JES. If you add a new function to a class that function must be inside the braces that define the class and outside of everything else or java will complain that your function belongs inside a class or interface. Student24 |
I agree with Jonny – if it says "class expected," that means that you don't have a class declaration in the file. Remember that we talked about this Friday – there should be exactly one class definition in every file. Mark Guzdial |
In most cases it should not be necessary to return the Picture. Your method should be public void unless you are doing something that creates a new Picture without modifying the old one(maybe if you are making a collage or something). If you arn't doing anything like this or have no clue what I am talking about make your function void and don't return anything. Student24 |
You're doing the right thing. If you want to write out your image so that you can share it in the Gallery, do x.write("mypicture.jpg") after your x.show(). Mark Guzdial |
Could you post the exact error message? Usually the filename and line number provide clues as to where the problem could be. This error message usually means that your "{" and "}" that separate your code into chunks that define classes, functions, ifs, loops, and many more are not lined up properly. If the line number points to the start of a function usually that function is outside of the class definition and you need to check that all of the curly braces align in the function above it. This can also occur if you accidentally comment out a curly brace. Student24 |
Which error? The "class expected" error? Or the "out of memory" error? Note: I will be in my office by 9 am tomorrow (Monday) and will be in Student Center by 10 am. Mark Guzdial |
Try spelling out the whole path, e.g. p3.write("C:/mypicture.jpg"). You won't be able to do .show.write – as we showed today in class with Turtles. Mark Guzdial |
Is your path somewhere writable? You won't be able to write to a CD, for example, or a readonly directory. Do you have a laptop that you can bring to Jonny or me for help? Or come see me after class Wed.? It does work (since the Gallery is filled with pictures!), so we have to figure out what's going wrong with your setup. Mark Guzdial |