 |
 |
Java & Compile Time errors
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
|
(Last edited by GlobalNomad; Aug 30, 2003 at 08:49 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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  .
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|