From: Carl P. <C.J...@hu...> - 2002-09-30 19:54:19
|
Dear all, I'm having problems using some code to simplify keyboard input for my students (Dr.Java version 20020814-0343; JDK 1.3.1; OS Mac OSX 10.2.1 - reported problems are also verified on a Solaris setup). The code I'm using is as follows: public class read { static public int getInt(String prompt) { System.out.print(prompt); BufferedReader In = new BufferedReader(new InputStreamReader(System.in)); while (true) { try { System.out.print("[GetInt]"); String s = (In.readLine()).trim(); int y = (new Integer(s)).intValue(); return y; } catch (Exception e) { System.out.println("Incorrect input format, please enter again: "); } } } } and the following is typed into the interactions pane: int x = read.getInt("enter: "); The result is that Dr.Java hangs with a spinning wrist watch. As far as I can tell, the problem seems to be that my code is assuming that keyboard input will be derived from the System.in stream. I guess that Dr. Java assumes that keyboard input derives from an alternative stream? Any help with this one or alternative code for simplifying keyboard input is greatly appreciated. Many thanks in advance, Carl. -- Dr. Carl Pulley (Lecturer) School of Computing and Mathematics, University of Huddersfield, email: c.j...@hu... Huddersfield WWW: http://scom.hud.ac.uk/scomcjp |
From: Charles R. <cr...@ri...> - 2002-09-30 21:48:03
|
At the moment, DrJava does not support reading from System.in within the Interactions pane. There are both logistical and pedagogic reasons for this, but I'm not sure what our final decision will be yet-- it's still a topic of discussion. There's some related information on this report: http://sourceforge.net/tracker/index.php?func=detail&aid=604309&group_id=44253&atid=438935 I'll try to keep you updated on our decision, but it might be worth looking into avoiding System.in (given the strengths of the Interactions pane). Charlie Carl Pulley wrote: > Dear all, > I'm having problems using some code to simplify keyboard input for my > students (Dr.Java version 20020814-0343; JDK 1.3.1; OS Mac OSX 10.2.1 - > reported problems are also verified on a Solaris setup). > > The code I'm using is as follows: > > public class read { > > static public int getInt(String prompt) { > System.out.print(prompt); > BufferedReader In = new BufferedReader(new > InputStreamReader(System.in)); > while (true) { > try { > System.out.print("[GetInt]"); > String s = (In.readLine()).trim(); > int y = (new Integer(s)).intValue(); > return y; > } catch (Exception e) { > System.out.println("Incorrect input format, please enter again: "); > } > } > } > > } > > and the following is typed into the interactions pane: > > int x = read.getInt("enter: "); > > The result is that Dr.Java hangs with a spinning wrist watch. > > As far as I can tell, the problem seems to be that my code is assuming > that keyboard input will be derived from the System.in stream. I guess > that Dr. Java assumes that keyboard input derives from an alternative > stream? > > Any help with this one or alternative code for simplifying keyboard > input is greatly appreciated. > > Many thanks in advance, > > Carl. > > -- > Dr. Carl Pulley (Lecturer) > School of Computing and Mathematics, > University of Huddersfield, email: c.j...@hu... > Huddersfield WWW: http://scom.hud.ac.uk/scomcjp > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Drjava-users mailing list > Drj...@li... > https://lists.sourceforge.net/lists/listinfo/drjava-users |
From: Charles R. <cr...@ri...> - 2003-05-30 04:53:17
|
We have just added support for reading input from System.in in the drjava-20030529-2239 development release. The program you mention below will now direct the user to enter input into the Console tab, which becomes editable when input is requested from System.in. Please give it a try and let us know what you think! You can download the release from the "more download options" link on http://drjava.org. Thanks, Charlie Reis On Mon, 30 Sep 2002, Carl Pulley wrote: > Dear all, > I'm having problems using some code to simplify keyboard input for my > students (Dr.Java version 20020814-0343; JDK 1.3.1; OS Mac OSX 10.2.1 - > reported problems are also verified on a Solaris setup). > > The code I'm using is as follows: > > public class read { > > static public int getInt(String prompt) { > System.out.print(prompt); > BufferedReader In = new BufferedReader(new > InputStreamReader(System.in)); > while (true) { > try { > System.out.print("[GetInt]"); > String s = (In.readLine()).trim(); > int y = (new Integer(s)).intValue(); > return y; > } catch (Exception e) { > System.out.println("Incorrect input format, please enter again: > "); > } > } > } > > } > > and the following is typed into the interactions pane: > > int x = read.getInt("enter: "); > > The result is that Dr.Java hangs with a spinning wrist watch. > > As far as I can tell, the problem seems to be that my code is > assuming that keyboard input will be derived from the System.in stream. > I guess that Dr. Java assumes that keyboard input derives from an > alternative stream? > > Any help with this one or alternative code for simplifying keyboard > input is greatly appreciated. > > Many thanks in advance, > > Carl. > > -- > Dr. Carl Pulley (Lecturer) > School of Computing and Mathematics, > University of Huddersfield, email: c.j...@hu... > Huddersfield WWW: > http://scom.hud.ac.uk/scomcjp > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Drjava-users mailing list > Drj...@li... > https://lists.sourceforge.net/lists/listinfo/drjava-users > |
From: Paulo J. da S. e S. <rs...@im...> - 2003-05-30 10:38:53
|
Hi, This is great news! IMHO, The ability to read from stdin was the major feature lacking in DrJava. Now, it really seems that DrJava is the perfect tool for our introductory Computer Science course. Great work, Charles! Paulo -- Paulo José da Silva e Silva Professor Assistente do Dep. de Ciência da Computação (Assistant Professor of the Computer Science Dept.) Universidade de São Paulo - Brazil e-mail: rs...@im... Web: http://www.ime.usp.br/~rsilva Teoria é o que não entendemos o (Theory is something we don't) suficiente para chamar de prática. (understand well enough to call practice) |
From: Marcelo de G. M. <mg...@th...> - 2003-06-01 18:59:35
|
Hello, > This is great news! IMHO, The ability to read from stdin was the > major feature lacking in DrJava. At first I thought this was a stumbling block for the traditional introduction to programming, but I found a neat class that was even easier for the students than the standard input mechanism (which includes some validation): http://cs.joensuu.fi/pages/ageenko/teaching/OOP/labs.htm Paulo, I've translated that to Portuguese, if you're interested... Thank you to all for this great tool! Marcelo |