Results 1 to 9 of 9
- 10-02-2008, 09:19 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
if else statements and using images
I am looking for a way to ask a user to choose between two images and upon their answer the appropriate image appears. It is for a class I am taking and we are suppose to do this using an if else statement. The suggestion that I have been given is to declare a static instance variable at the beginning of the class. I was wondering if anyone has any other suggestions on how to do this?
- 10-02-2008, 09:32 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
What do you think? Make a start and see how far you come. Than ask again.
I die a little on the inside...
Every time I get shot.
- 10-02-2008, 10:13 PM #3
Break the problem down into separate steps.
1) Ask a question and get a response from a user.
2) display an image
You can use a static variable but it is NOT needed.
Design the program first, then decide how to implement it.
- 10-02-2008, 10:19 PM #4
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Why static anyways?
I die a little on the inside...
Every time I get shot.
- 10-03-2008, 06:08 PM #5
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
The static variable was just the suggestion given by the instructor. I thought that it was because you can only use static variables with static methods. However after doing some reading and messing around with this last night I think I have figured out a way to do this. The problem I am having now is when I attempt to assign the graphic to a variable I am getting an illegal start of expression error. I am troubleshooting this now to the best of my ability however i have only been doing this for like 6 weeks, so it is still incredibly new to me.
- 10-03-2008, 06:28 PM #6
Member
- Join Date
- Oct 2008
- Posts
- 5
- Rep Power
- 0
Can u give more information on the error. Any stack trace ?
- 10-03-2008, 06:59 PM #7
When you get an error, copy and post the full text here. There is info in it that will help solve the problem.
- 10-05-2008, 05:34 PM #8
Member
- Join Date
- Oct 2008
- Posts
- 10
- Rep Power
- 0
maybe its a user error
type the whole problem so we can see the error
- 10-05-2008, 06:51 PM #9
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Similar Threads
-
Need help - using algorithm statements
By javanewbie in forum New To JavaReplies: 2Last Post: 07-23-2008, 11:20 AM -
avoiding if statements
By valoyivd in forum New To JavaReplies: 1Last Post: 04-02-2008, 09:08 AM -
Help with actionPerformed Statements
By wco5002 in forum New To JavaReplies: 8Last Post: 03-26-2008, 04:02 AM -
Help with if else statements
By zoe in forum New To JavaReplies: 1Last Post: 07-24-2007, 07:56 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks