• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with Item/String getting input?  RSS feed

 
John Bowmen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quick answer: You can often use String.valueOf(something) to create a string out of another type, but I haven't tested it.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Bowmen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!