Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Java & Compile Time errors

Java & Compile Time errors
Thread Tools
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Aug 30, 2003, 12:22 AM
 


Ok.

I am pretty new to java, this is kinda like my first 'big' application (okay its pretty big for me ).


Why can't i get the variable menuOption to be displayed from the public void run() ?




edit: removed my crappy code
(Last edited by GlobalNomad; Aug 30, 2003 at 08:49 AM. )
     
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Aug 30, 2003, 12:25 AM
 
For some reason if i try to use
int whichOne() {
instead of
public void whichOne() {
It doesn't work???
I think it works with windows (don' have a Windows machine around me)



Help would be greatly appreciated
     
Forum Regular
Join Date: Jul 2001
Location: Québec, Canada
Status: Offline
Reply With Quote
Aug 30, 2003, 05:13 AM
 
Of course if you had provided us with your compile errors it would have been easier.

This line seems problematic to me:
Code:
writer.println("menuOption " + menuOption);
because the variable menuOption is an int. You cannot concatenate a string with another data type in java without first explicitly converting that type to a string. Use String.valueOf(menuOption) to convert menuOption to a string.

As for the second question I don't know. What are the errors?
     
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Aug 30, 2003, 05:23 AM
 
Yeah that line was just like a test line.
thanks for the help with the int value .

Okay I'm almost done.
All I need to do is:

1. I need to let the person enter in coins with cent value.
- 10, 20, 50, 100, 200 (Australian Style).
Is there a way to limit input only to thoes numbers, and tell the person if they have entered an illegal value and to start again? (I tried some boolean, while loop thing but that didn't work ).

2.
How can I make it pause at the end of the loop until the person hits enter or 'any key'?


Thanks very mutch for the help
     
Forum Regular
Join Date: Jul 2001
Location: Québec, Canada
Status: Offline
Reply With Quote
Aug 30, 2003, 08:13 AM
 
What kind of while loop did you try? A while loop is all you need for number 1.

For number 2, you should check the KeyboardReader class you use. I don't know that class but it may or may not have such facilities. Maybe you could try reading a char and ignore the value.
     
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Aug 30, 2003, 08:25 AM
 
Okay 2. was easy
With TerminalIO (keyboardreader & screenwriter) all you do is:
reader.pause();
(and it types out on the screen, hit any key to continue).

1. Is a little more difficult .
     
   
Thread Tools
Forum Links
Forum 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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2