Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 29th, 2004, 5:26 PM   #1
JawaKing00
Newbie
 
Join Date: Sep 2004
Posts: 29
Rep Power: 0 JawaKing00 is on a distinguished road
Ok,

For my Java class I need to implement the Farmer/Wolf/Goat/Cabbage puzzle.

For the input to the program I am to use command line arguments that will be just the letters E or W indicating which side of the river each thing is on and which side they should be on when finished.

What I want to do is take the String arguments passed and change them into char variables so I can easily compare them and such. I can't seem to figure out how to change a string of one letter into a char though.

Can anyone give me some form of advice?

Thank you.
JawaKing00 is offline   Reply With Quote
Old Nov 29th, 2004, 5:49 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
char c = str.charAt(0);
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 29th, 2004, 7:34 PM   #3
JawaKing00
Newbie
 
Join Date: Sep 2004
Posts: 29
Rep Power: 0 JawaKing00 is on a distinguished road
Thank you.

I knew it had to be something simple, I just wasn't finding it
JawaKing00 is offline   Reply With Quote
Old Nov 30th, 2004, 6:08 PM   #4
eccles
Newbie
 
Join Date: Nov 2004
Posts: 16
Rep Power: 0 eccles is on a distinguished road
isn't there also a way to read from System.in char by char?
eccles is offline   Reply With Quote
Old Nov 30th, 2004, 9:40 PM   #5
KwizatzHaderach
Newbie
 
Join Date: Nov 2004
Posts: 8
Rep Power: 0 KwizatzHaderach is on a distinguished road
char[] inputChars=input.toCharArray();
char inp=inputChars[0];
KwizatzHaderach is offline   Reply With Quote
Old Nov 30th, 2004, 10:38 PM   #6
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Fixed code tags in post preceding mine.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting 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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC