raniero
15-09-2005, 13:07
Ciao, vorrei Scrivere su un semplice file . txt, il contenuto della matrice macchine[][] che ho creato in questo file sottostante: qualcuno saprebbe darmi una dritta?
grazie!
import java.util.Timer;
import java.util.TimerTask;
import java.io.*;
public class Lavori {
Timer timer;
int x = 0;
int v[]=new int[5];
static int macchine[][] = new int[101][6];
static int b=0;
public void Reminder(int seconds) {
timer = new Timer();
x= (int)Math.round(200*Math.random());
timer.schedule(new RemindTask(), x*100, seconds*100);
}
class RemindTask extends TimerTask {
public void run() {
int co= 0;
int i=0;
while ( i < 4 ) {
v[i]= (int)Math.round(3*Math.random());
i++;
} // fine while
macchine[++b][0]=(b);
macchine[b][1]=x;
macchine[b][2]=v[0];
macchine[b][3]=v[1];
macchine[b][4]=v[2];
macchine[b][5]=v[3];
++co;
if (co==1) {
timer.cancel();
}
} // fine run
} // fine remindtask
} // fine crea
grazie!
import java.util.Timer;
import java.util.TimerTask;
import java.io.*;
public class Lavori {
Timer timer;
int x = 0;
int v[]=new int[5];
static int macchine[][] = new int[101][6];
static int b=0;
public void Reminder(int seconds) {
timer = new Timer();
x= (int)Math.round(200*Math.random());
timer.schedule(new RemindTask(), x*100, seconds*100);
}
class RemindTask extends TimerTask {
public void run() {
int co= 0;
int i=0;
while ( i < 4 ) {
v[i]= (int)Math.round(3*Math.random());
i++;
} // fine while
macchine[++b][0]=(b);
macchine[b][1]=x;
macchine[b][2]=v[0];
macchine[b][3]=v[1];
macchine[b][4]=v[2];
macchine[b][5]=v[3];
++co;
if (co==1) {
timer.cancel();
}
} // fine run
} // fine remindtask
} // fine crea