Forums Register Login

Problems with Item/String getting input?

+Pie Number of slices to send: Send
Sorry if I am making no sense, I dont have much practise
Hello, I have set up Items to hold a set of chars which are meant to be placed on a text based map, however when i am asking for the char, there is an error stating that it must be a string type. Is there any way to convert my Items to strings, or allow the input of an Item? Thanks in advance
The error is where the user is trying to enter a symbol.

1
+Pie Number of slices to send: Send
Quick answer: You can often use String.valueOf(something) to create a string out of another type, but I haven't tested it.
1
+Pie Number of slices to send: Send
Welcome to the Ranch

Lots of little things, I am afraid.
I had to break your line 119 because it was too long. Also your indentation and spaing are inconsistent which makes you r code hard to read: look at lines 100-107. Don't use \n unless you have been asked for the LF character. Even less
System.out.printf("\n");
Use
System.out.println();
instead. String.valueOf() will definitely work; it calls toString unless you manage to pass null in which case you get the String "null". You can probably get your Item objects via a valueOf method as well, assuming Item is an enumerated type.
+Pie Number of slices to send: Send
Thanks:)
All of the following truths are shameless lies. But what about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 512 times.
Similar Threads
Loop problem java exercice
Grid, vector, magnitude app
why my results can't pass the 999 limit?
Help printing output for Contact Manager assignment
Help with splice
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:07:07.