Current location: Hot Scripts Forums » Programming Languages » Everything Java » a bit of help


a bit of help

Reply
  #1 (permalink)  
Old 02-28-10, 01:08 PM
DamienCourt DamienCourt is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
a bit of help

Hi guys
just want to know if there's anything wrong with this statement:

if ( (slot1.getIcon() == slot2.getIcon() ) && (slot1.getIcon() == slot3.getIcon() ) && (slot2.getIcon() == slot3.getIcon() ) )
......

i have a similar statement where i use '||' and it works fine.but this one doesn't.it doesn't produce an error it just ignores it
Any suggestions?
Reply With Quote
  #2 (permalink)  
Old 02-28-10, 06:23 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Are all three values identical?
Reply With Quote
  #3 (permalink)  
Old 03-01-10, 11:35 AM
DamienCourt DamienCourt is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
yes . it's part of a slot machine simulator. it's supposed to compare the images, which are displayed on each slot(i use JLabel to display them). If it's the same image in each slot then execute some code.
Reply With Quote
  #4 (permalink)  
Old 03-01-10, 03:21 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
You could try this:

one=slot1.getIcon();two=slot2.getIcon();three=slot 3.getIcon();
if ((one==two)&&(two==three)&&(one==three))

The difference is that getIcon is only called once per slot.
Reply With Quote
  #5 (permalink)  
Old 03-06-10, 07:26 AM
DamienCourt DamienCourt is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
it didn't work...thanks anyway i'll keep tryin
Reply With Quote
  #6 (permalink)  
Old 03-06-10, 07:38 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Might be a type issue.

What type does .getIcon return?
Reply With Quote
  #7 (permalink)  
Old 03-08-10, 06:03 AM
DamienCourt DamienCourt is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
i'm an idiot it had nothing to do with the syntax. I just should have placed the '&&' statement before the '||' one.It was such a bloody simple thing!!!!!
thanks for trying to help
Reply With Quote
  #8 (permalink)  
Old 03-08-10, 07:08 PM
liumingwei2010 liumingwei2010 is offline
New Member
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
I am a chiness.just try use english bbs.this is my first time.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I change a movie (.avi or any toher extention) bit to flash? Hsekhar Flash & ActionScript 4 10-30-09 09:11 PM
Running Java on 32 and 64 bit Imaizumi Everything Java 0 06-03-09 11:40 PM
how to install win32::GuidGen on windows 64 bit OS dattaforit Perl 1 02-27-09 11:44 PM
bit and byte question zoliky C/C++ 3 01-14-07 05:26 PM
Bit of C++ help needed....arrays kvnband C/C++ 2 09-08-06 05:48 AM


All times are GMT -5. The time now is 05:49 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.