Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-22-2004, 09:03 PM   #1
Member (7 bit)
 
Join Date: Sep 2004
Location: IU Bloomington
Posts: 119
Send a message via AIM to damontgo
Java help

Hey, I'm using Dr. Java in my intro to programming class at IU. We need to write this class (in the attached file) not using 'if' statements. I think i need to use the boolean operators ! && || to accomplish this. From what i've read, however, this will only output results of True or False. I need to be able to check the value of my String message (current code also attached) to see if its null, then output 1 of 2 statements based on its being true or false. If anyone can help me please, i would be very grateful.
Attached Files
File Type: doc ddhw3.doc (25.0 KB, 90 views)
File Type: doc code.doc (20.0 KB, 50 views)
damontgo is offline   Reply With Quote
Old 09-24-2004, 09:23 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Is it OK to use the ?: operator?
Code:
return message == null ?
    "there's no message here" : "there's one message waiting for pickup";
The only way I can come up with using conditional operators is quite complicated, and I doubt this is what they want.
aym is offline   Reply With Quote
Old 09-28-2004, 09:21 AM   #3
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Don't mess with nulls if you don't have to. Make your default message an empty string ("") and use a switch statement to do the comparisons.
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:53 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2