Questions on HW8-Spring08
public int nextINT( int radix){
Scanner sc= new Scanner(new File("bumpers"));
while(sc.nextINT(){
int nextINT= sc.nextINT();
}
should this work for the first part
once we create a method for file input in the Model class - where are we supposed to call it?
The doPaint method I believe....Dawn Finney
When I run this, it never enters the while loop but it also doesn't stop running and I don't get any error messages.
public static int[] cellInput() throws java.io.FileNotFoundException
{
String cellinputfile = FileChooser.pickAFile();
System.out.println("working");
int cellarray[] = new int[104];
System.out.println("working");
StringTokenizer st = new StringTokenizer(cellinputfile,",");
System.out.println("working");
int i = 0;
while(st.hasMoreTokens());
{
System.out.println("working");
int cellvalue = Integer.parseInt(st.nextToken());
cellarray[i] = cellvalue;
System.out.println(cellarray[i]);
i++;
}
System.out.println("working");
return cellarray;
}
- Does your file have commas in it? You can't use comma as a delimiter if your file does not have commas in it. Dawn Finney
yes my file has commas after every number
- Oh your StringTokenizer only tokenizes the filename and not the file itself. You should have a Scanner or BufferReader give you each line of the text file and have StringTokenizer tokenize it for you. Dawn Finney.
I don't understand what the data file is supposed to have.
when I add my file input method (which is static) to the doPaint() method I get an error stating i must declare a file not found exception for that method and then any other method that calls doPaint() even though i already declared one for the file input method itself - is this supposed to happen and if not what should I do?
- If your input method throws the exception then it should be handled in a try-catch block inside of doPaint. If your input method actually uses a try-catch block then I don't know. Dawn Finney
if our input method is supposed to have a filechooser and we are supposed to call it in doPaint - won't this ask for a file every timer tick since doPaint is called every timer tick?
- It should only call the FileChooser at the beginning and not prompt the user every time. Figure out how to do this. Dawn Finney
we are confused on what we should do after we write the scanner.
- Go look at the doPaint method. You have to draw the boxes next. Dawn Finney
hi,in recitation it was said that the homework was going to have the grace period extended until friday...is that true.
- FALSE I will extend the grace period slightly because of the homework help session but not until Friday. Dawn Finney.
can we assume you will use the starting configuration file we submit with the hw?
- You can assume we will test with the same format but not necessary the same file. Dawn Finney
Since it only needs to be done once, why couldn't we put our scanner code in the Model() constructor?
- You can. In fact in retrospect, it is easier to do it in the constructor but regardless the scanner stuff should only be called once in the beginning. Dawn Finney
When I apply the GridLayout to Global.myPanel in the doPaint() method, nothing changes. On that note... I can't find doPaint() being called anywhere in the code, but the background color is changing, and the only place that's done is in the doPaint() method. If I try to apply the layout in the constructor (which doesn't really make sense, I guess), I get a NullPointerException.
is there a checklist for this hw
my game works but some of the larger configurations that I input lead to progressions that run for a pretty long time - should all original configurations lead to progressions that die off or reach a stable state relatively quickly
The one that keeps running is a 40 by 40 grid with about half of the cells originally alive. Is it just too big or is there something wrong with how I executed the rules?
I can see the stable state figures popping up every now and then so I think the I executed the rules correctly
Also some of my smaller (10 by 10) configurations actually do end up in stable states or dying off
this line freezes everything, any idea why?
Scanner scan = new Scanner(new File(FileChooser.pickAFile()));
- It's 'cause FileChooser sucks. Try putting that stuff in the constructor. Dawn Finney
For some reason, only the first "move" in my game of life works correctly. After that, cells don't generate and die by the rules. The way I'm updating is by creating a new matrix based on an application of the rules to the old matrix, then setting the old matrix equal to the new matrix. Is there something wrong with this methodology?
- Maybe your rules are wrong. Maybe your new matrix is wrong. A bunch of things could do be wrong which is why you have to go and do some printlns and see what's going on. Dawn Finney
Link to this Page