This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Smiling Face Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Smiling Face" Watch "Smiling Face" New topic
Author

Smiling Face

Andrew Hocker
Greenhorn

Joined: Feb 05, 2004
Posts: 13
This is a homework assignment that I'm have some trouble with. Since it's an assignment, I was wondering if someone could kind of lead me in the right direction but not give me the answers. The two files are below, java and class.
Class

Implementation of the class


I don't really know anything, google does though.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Could you please tell us what kind of trouble? Does it compile? What are the error messages, if not? If it runs, does it not do what you expect? What do you expect, and what happens instead?


[Jess in Action][AskingGoodQuestions]
Andrew Hocker
Greenhorn

Joined: Feb 05, 2004
Posts: 13
lol, really sorry about that. I forgot to include my list of problems that are occurring. First of all, a smiley face is supposed to show and does, but when you choose for it to be sad it just draws the angled sides of the mouth and nothing else.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

The way your erase method works is a bit dangerous - you're drawing the face as white over top of the current face. On top of that, your erase() calls draw() and then you call draw() yourself.
Java is not command line. It sounds weird, but it's possible that the erase's call to draw() might be coming after your own call to draw(). In other words it would draw the sad face and then draw the "erase" happy face on top of it.
The infinite loop is dangerous as well and may be contributing to the problem. Consider learning how to use event listeners as while(true) rarely gives positive results.


A good workman is known by his tools.
Andrew Hocker
Greenhorn

Joined: Feb 05, 2004
Posts: 13
What's an eventListener and how can I use one in my case?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I assume you are writing an applet. Being that this is a homework assignment also leads me to assume you have a textbook. Any Java textbook should have a bit on event listeners - that would be a good source for learning.
I really can't give much more advice without knowing how your program is designed, if you're using Swing, etc.
 
 
subject: Smiling Face