{"author_name":"longcatlover","cat":"LD #26","comments":[{"author_name":"pirate-rob","time":"April 17, 2013 6:26 am","epoch":1366197960,"text":"Wow, I never knew java user input was this easy, rather helpful, thanks!","spam":"N"},{"author_name":"","time":"April 17, 2013 9:03 am","epoch":1366207380,"text":"The take method will not work &#8211; you can&#8217;t use Strings as an output in Java because they are immutable. Your sample will always output &#8220;You said: !&#8221;","spam":"N"},{"author_name":"bitcrusher","time":"April 17, 2013 9:28 am","epoch":1366208880,"text":"Your say method won&#8217;t work. Try&#8230;","spam":"N"},{"author_name":"bitcrusher","time":"April 17, 2013 9:43 am","epoch":1366209780,"text":"Have your take method return a String:","spam":"N"},{"author_name":"LlamaHarmer","time":"April 17, 2013 11:14 am","epoch":1366215240,"text":"You thought about using the Console?","spam":"N"},{"author_name":"SuperDisk","time":"April 17, 2013 12:57 pm","epoch":1366221420,"text":"The &#8220;take&#8221; method won&#8217;t work. First, you&#8217;re modifying a reference, and you&#8217;re not freeing the Scanner sc, causing a memory leak.","spam":"N"},{"author_name":"EatenAlive3","time":"April 20, 2013 5:15 pm","epoch":1366496100,"text":"For take, try:","spam":"N"},{"author_name":"Shadow12345","time":"August 20, 2013 6:32 pm","epoch":1377041520,"text":"Hey! what about sysout?","spam":"N"}],"epoch":1366192680,"likes":3,"metadata":{"p_key":"47087","p_author":"longcatlover","p_authorkey":"20816","p_urlkey":"82750","p_title":"To all Java Text-Based game makers!","p_cat":"LD #26","p_event":"LD26","p_time":"1366192680","p_likes":"3","p_comments":"8","p_status":"UPD5","us_key":"20816","us_name":"longcatlover","us_username":"longcatlover","event_start":"1366934400","event_key":"16","event_name":"LD26"},"text":"<p><em>Hello! I am planning to make a text-based game this year in the Ludum Dare, and I realized how lazy I am&#8230;so lazy that I find it hard to keep typing &#8220;System.out.println(&#8220;walri rock!&#8221;)&#8221;, so I thought of this:<\/em><\/p>\n <p>In the beginning of your main class, make 2 methods, a &#8220;say&#8221; method and a &#8220;take&#8221; method, these will work as the cin and count in C++, the say method would be the following:<\/p>\n <p><code>public static void say(String message){<br \/>\n System.out.println(say);<br \/>\n }<\/code><\/p>\n <p>And make the take method the following:<\/p>\n <p><code>public static void take(String takeTo){<br \/>\n Scanner sc = new Scanner(System.in);<br \/>\n takeTo = sc.nextLine();<br \/>\n }<\/code><\/p>\n <p>And TA-DA!!! I am stating now though, that I have NOT tested the take method&#8230;Anyhow, you would use the code like this:<\/p>\n <p><code>\/\/This is a simple intake\/output thingy majogger<br \/>\n String input = \"\";<br \/>\n say(\"Say something!\");<br \/>\n take(input);<br \/>\n say(\"You said: \" + input + \"!\");<br \/>\n <\/code><\/p>\n <p>Fell free to use any of this code, and Good Luck to all!!!!!<\/p>","time":"April 17th, 2013 4:58 am","title":"To all Java Text-Based game makers!"}