Computer Science Canada converting int to string |
Author: | ahmhum [ Sun Apr 12, 2009 7:38 pm ] | ||||
Post subject: | converting int to string | ||||
Ok I'm trying to convert int to string and i dun know how to, so plzz help me out here is wat im tryin to convert
so instead of it being face == 1 i want it to be 1A or 1B and so on thnx in advance Mod Edit: Remember to use syntax tags! Thanks ![]()
|
Author: | Dark [ Sun Apr 12, 2009 9:33 pm ] | ||||
Post subject: | RE:converting int to string | ||||
Didn't read your code but this is how to convert an int to a string.
In case you are wondering on how to convert a char value into a String,
|
Author: | ahmhum [ Sun Apr 12, 2009 10:10 pm ] |
Post subject: | RE:converting int to string |
it doesn't work even when i did that |
Author: | ahmhum [ Sun Apr 12, 2009 10:20 pm ] |
Post subject: | RE:converting int to string |
ok nvm it did work |
Author: | ahmhum [ Sun Apr 12, 2009 10:37 pm ] |
Post subject: | RE:converting int to string |
ok now i want to convert char value to String but what you told me to do Dark, it doesn't work |
Author: | Dusk Eagle [ Sun Apr 12, 2009 10:38 pm ] |
Post subject: | Re: converting int to string |
Just out of curiosity, are you making a Death Note game? |
Author: | Tony [ Sun Apr 12, 2009 10:51 pm ] |
Post subject: | RE:converting int to string |
You'd think that he'd actually use "Shinigami" then. The reference to "Hollow" makes me think Bleach, although I haven't seen nearly enough of that series to be sure. @ahmhum -- in what way does it not work? |
Author: | ahmhum [ Sun Apr 12, 2009 10:57 pm ] |
Post subject: | RE:converting int to string |
it says tht the char is not defined char c = 'k'; String value = Character.toString(c); so (c) is not defined is what i get nd yea its a bleach game |
Author: | ahmhum [ Sun Apr 12, 2009 11:00 pm ] |
Post subject: | RE:converting int to string |
oo and i want it to read two character so like 1A and not just 1 or A or w/e |
Author: | ahmhum [ Mon Apr 13, 2009 12:11 am ] | ||
Post subject: | RE:converting int to string | ||
ok this is what I want to convert from char to String
thnx in advance |
Author: | Tony [ Mon Apr 13, 2009 12:29 am ] | ||
Post subject: | RE:converting int to string | ||
No. |
Author: | ahmhum [ Mon Apr 13, 2009 1:20 am ] |
Post subject: | RE:converting int to string |
what do u mean no |
Author: | wtd [ Mon Apr 13, 2009 2:17 am ] |
Post subject: | RE:converting int to string |
He means that's the wrong way to write that bit of code. Notice the pattern. Make your code simpler. |
Author: | wtd [ Mon Apr 13, 2009 2:19 am ] | ||
Post subject: | RE:converting int to string | ||
Also horribly wrong:
|
Author: | Dark [ Mon Apr 13, 2009 10:05 am ] |
Post subject: | RE:converting int to string |
those should be else ifs, after the first if. Also, use a switch statement for those ifs. Or, better yet, let play = input. parse the char into an int. |
Author: | Insectoid [ Mon Apr 13, 2009 10:22 am ] |
Post subject: | RE:converting int to string |
What about Integer.parseInt? Or is that to go from string to integer? |
Author: | wtd [ Mon Apr 13, 2009 10:55 am ] |
Post subject: | RE:converting int to string |
Yes, yes, and you missed one. What happens if face is 1, and what happens if it's 2? |