LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 407 users online 184923 members 330 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
6 online / 12 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Can you do this? (Java)
Replies: 2Last Post Oct. 15 6:33pm by PatrickTheGreat
Single page for this topic Email Print Favorite
( Majo )


Soothsayer
Reply
I need help with this program, I'm totally confused.

In my main program, I'm asking the user to choose what sort of item he/she wants to order, a widget (w) or a gadget (g).

In my functional class, I'm checking to see if that's valid. If they don't enter either a g or a w, I have to print out an error message and let them keep trying until they get it right.

My boyfriend said that I can't check whether they've put it in right in the functional class if all the I/O is in the main program and said that I should do that loop/switch/whatever it's supposed to be in the main program.

Can't you do that in the functional class though? I'm so confused.

-------
"Under the hardness of her facade a woman's heart is still beating."


1:29 pm on Oct. 11, 2008 | Joined May 2005 | 268 Days Active
Join to learn more about Majo Pennsylvania, United States | Straight Female | 6369 Posts | 11015 Points
sakurag


Soothsayer

Patron
Reply
Something like:


public int OrderItemCheckString(string strOrderItem) {
if (strOrderItem == null) {
return (int)E_NULL_STRING;
}

if ( good condition ) {
return (int)S_OK;
}

return (int)E_INVALID_STRING;
}

Then in your main.. you can use this to check the value.
However, I would create  
public int AddOrderItem(string strOrderItem). Use the above method within it, and make it private.

Send me a PM if this doens't make sense.  You should think of main as just a launching pad for what you do.  Unless I'm tossing together a quick prototype, there is very little code in main..

Post edited at 3:59 pm on Oct. 15, 2008 by sakurag

-------
I've got spurs that jingle jangle jingle.
As I go riding merrily along.
And they sing, "Oh, ain't you glad you're single?"
And that song ain't so very far from wrong.


3:56 pm on Oct. 15, 2008 | Joined Oct. 2002 | 573 Days Active
Join to learn more about sakurag Washington, United States | Straight Male | 2254 Posts | 10202 Points
PatrickTheGreat


Dairy Product Addict
Reply
Use an If and or an If Else

-------
-@p4ddy-I'm the operator with my pocket calculator.
http://pkmtech.net/

6:33 pm on Oct. 15, 2008 | Joined Feb. 2006 | 125 Days Active
Join to learn more about PatrickTheGreat Michigan, United States | Straight Male | 523 Posts | 1907 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic