PeopleGalleryZombiesFrolfProf ReviewsDictionaryBuy/SellForumsMovies

Sign In | Join


  » DormWire / Technical Forums / Programming & Application Development / Viewing Topic

Can you do this? (Java)
Replies: 2Last Post Oct. 15 6:33pm by PatrickTheGreat

(+) New Topic   (+) New Poll (+) Add Reply
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
(+) New Topic   (+) New Poll (+) Add Reply

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  » DormWire / Technical Forums / Programming & Application Development / Viewing Topic



  © 2008 DormWire | Custom Web Hosting | Terms of Use | Site Map | Contact | FAQ