DK
Junior Member
Posts: 23
|
Post by DK on Nov 27, 2001 13:41:35 GMT -5
urgh..just ignore what I said previously gundam. I wasn't thinking properly(was thinking of it differently. )your way looks fine. thanx for your help. quoted from pervious "When you want to read something from the keyboard, you will have to call a method in the input/output class which reads from the keyboard and returns the information to the calling method as a return value." i thought that has to be in the same method so....what's the point of having my Input method int when i'm not even gonna return the values using that method? i'm just gonna stick to my old one which is public int getRowGuess() { return rowguess; } and public int getColumnGuess() { return columnguess; } is that right???
|
|
|
Post by Sylph on Nov 27, 2001 14:47:34 GMT -5
and how did you guys do the display of the grids? I used System.out.println("........") but that doesnt work too well... is there something that works like printspace instead of line... that way is concats onto the same line instead of starting a new one? do u mean like System.out.print("..."); //?
|
|
|
Post by SquirrelHunterPro on Nov 27, 2001 19:33:46 GMT -5
this is what I have in mine...
import java.io.*;
public class TheRealInputOutput{ static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//******************************************
public static String input()throws IOException{ return in.readLine(); }
//******************************************
public static void OutputMessage(String msg){ System.out.println(msg); }
//****************************************** }
|
|
|
Post by Brutal_Chicken on Nov 27, 2001 20:06:42 GMT -5
do u mean like System.out.print("..."); //? Why don't you use a 'for' loop to print things out on the same line? Use System.out.print (not println) to print things on the same line. Two for loops should do the trick.
|
|
|
Post by 1.8T on Nov 27, 2001 22:30:24 GMT -5
??. so is it "legal" to put throws IOException in main ??.,
ok i have public String userInput () throws IOException{
in my I/O class,
and it returns a string, ., i change it to an int in some other class.,., anyways.,
i get this error: Error : Exception java.io.IOException must be caught, or it must be declared in the throws clause of this method. drawGrid.java line 92 int userRowValue = Integer.parseInt(inOut.userInput());
any ideas wut's going on?,.
i've tried putting throws IOException in the main class as well., still don't work.
|
|
|
Post by Observer on Nov 28, 2001 2:01:16 GMT -5
To display my grid I used System.out.println inside of two overall for loops (one for column on for row) but there may be other ways to do it. I also used the new line "\n" thing.
|
|
DK
Junior Member
Posts: 23
|
Post by DK on Nov 29, 2001 17:48:11 GMT -5
it's legal --asked a T.A. dunno what's going on with your code though. ??. so is it "legal" to put throws IOException in main ??., ok i have public String userInput () throws IOException{ in my I/O class, and it returns a string, ., i change it to an int in some other class.,., anyways., i get this error: Error : Exception java.io.IOException must be caught, or it must be declared in the throws clause of this method. drawGrid.java line 92 int userRowValue = Integer.parseInt(inOut.userInput()); any ideas wut's going on?,. i've tried putting throws IOException in the main class as well., still don't work.
|
|
|
Post by gundamf91 on Nov 29, 2001 19:01:28 GMT -5
in your BoneDig method you also have to throws IOException after your public static blah blah blah and to import java.io*; at the beginning
i tried it
gundamf91
|
|
|
Post by kermit on Nov 29, 2001 23:58:03 GMT -5
umm... :-/just wondering... this is what the handout says: "When you want to read something from the keyboard, you will have to call a method in the input/output class which reads from the keyboard and returns the information to the calling method as a return value." does this mean we must return the value inputted from the keyboard once we call the input method? in the methods in your IO class, the BufferedReader inputs are of String type. you have to change then to ints, then return the ints so that in main, when you call the input methods from your IO class, you will get ints back and you can use those int values as index values in your array (to check if there is a bone there or not, etc...). does that help?
|
|