Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Questions on HW1-Sp2005

Any questions on implementing a picture method? Ask them here? (Got an answer for someone else? Feel free to make a suggestion!)


Is the assignment to use one of the methods defined in Picture.class on a picture to change the way it looks or to create our own method that does something different than all the methods in the Picture.class? -Not dazed, but confused

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

So what we turn in to WebCT is the Picture.class file with our function, named according to what it does, at the very bottom of the file with a comment above it stating our name and what it does? -Still a little confused
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

I have written the program but I can't get Dr.Java to actually find the java files to run the program I have written. I've completed all the steps in the notes, especially adding the jar file to the Tools.jar location but it still seems like its not locating the class files I need to run the program. Any suggestions? Thanks!

You might have input the wrong location for the java-source folder in preferences when adding extra classpaths.
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

Are the slides from lecture available online?
Yes on the course homepage 2nd link from the bottom. Student24

does anyone know what i'm doing wrong?

for some reason dr. java is not recognizing the methods in picture.java.

> Picture p = new Picture(FileChooser.pickAFile())
> p.flip()
Error: No 'flip' method in 'Picture'

this is after compiling and this happens for all the methods. but i can: p.show()
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


Why does the pickAFile() window come up behind DrJava? And has anyone figured out how to fix that?

I might have found the answer. When the DrJava window is maximized to fill the entire desktop, the pickAFile() window displays on top. Atleast it does on my computer.

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

I actually posted and answered that question. I posted it because I hated it showing up on bottom and then found out how to show it on top. I thought I'd just answer it for everyone to know. Student50


Thanks, Charlie! Mark Guzdial


How can we upload our manipulated pictures to show in the gallery? (What's the username and password?)
Student45

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


for the hw- I'm trying to use the dereaseGreen and decreaseRed methods at the same time– is that ok for this assignment? I've tried to perform them at the same time, but i get "out of memory" error? Why?
gtg749y- Yuka
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


Just a note~When I hit "compile all" and for the compiler output, I get an Error:
File: (no associated file) [line: (no source location)]
Compile Exceution: java. lang.OutOfMemoryError
Yuka- gtg749y



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




I'm getting the same error as Yuka, but I am modifying the original. When I compiled it to begin with it was fine, and I really don't think it is my memory.
~REMOVEDdsay
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

Should the comment with our name, etc. be at the top or bottom of Picture.java?
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

For this assignment, I am trying to decrease Red and Green at the same time. I have compiled the document and it told me that it was compiled successfully. I even tested it by typing– defining a variable p in 'picture', decreaseRed and decreaseGreen– and the picture I picked from the media sources decreased red and green. So- now, I just have to turn in the document "Picture" (with my comments and code) through webct?
Thanks for reading this- I just wanted to make sure I'm on the right track.

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


Hey! I copy and paste increaseRed() to the bottom of the page and hit "Compile All" without changing anything in the code, and Java tells me that:

1 error found:
File: C:\1316JAVA\java-source.1\java-source\Picture.java [line: 2277]
Error: 'class' or 'interface' expected


Scary! Any ideas? Thanks! ;)

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

Should we return the image in the code we submit to be graded? If so, what is the command? "Return this" doesn't work. Should we just make it a "Public void" method? Right now, That's what I turned in, a Public void method, requiring the grader to x.methodname() and x.show().
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

I'm having the same problem with the Error when i "Compile All". Could you please elaborate on a solution to this problem? Thank you.
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



I cannot save my revised picture to a file. Here are my attempts:

> p3.show().write("mypicture.jpg")
Error: No 'write' method in 'void'

and then
> p3.show()
> p3.write("mypicture.jpg")
Couldn't write out the picture to the file mypicture.jpg

Please help!




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


Nope, that doesn't work either.


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



Link to this Page