package MyraTools;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.*;
@SuppressWarnings("serial")
public class RoundManager
extends JPanel {
// text fields
static boolean checks[];
};
// scritte
new JLabel("Numero Utenti: "),
new JLabel("Numero Compiti: ")
};
public RoundManager() {
this.setBounds(0,0,100,200);
VoidPanel p[] = {
new VoidPanel(),
new VoidPanel()
};
int a = 1;
// aggiungo elementi tramite Array di oggetti
while(a >= 0) {
p[1-a].add(labels[1-a]);
p[1-a].add(fields[1-a]);
a--;
} a = 1;
while(a >= 0) {
this.add(p[1-a]);
a--;
}
add(t1);
go.addActionListener(new Generator());
add(go); // bottone di invio
}
public boolean allChecked() {
int i = checks.length - 1;
System.
out.
println(checks.
length);
while(i >= 0) {
if(!checks[i]) return false;
i--;
}
return true;
}
public boolean isChecked(int a) {
if(checks[a])
return true;
else
return false;
}
int doc = 0, pat = 0;
doc
= Integer.
parseInt(fields
[0
].
getText());
pat
= Integer.
parseInt(fields
[1
].
getText());
checks = new boolean[doc];
while(((pat >= 1)||(doc >= 1)) && !allChecked()) {
int temp = gen.nextInt(doc);
while(isChecked(temp)) {
temp++;
}
t1.setText(t1.getText()+"Al Utente " +
doc + " è stato assegnato il Compito" +
" " + (temp+1) + "\n");
checks[temp] = true;
pat--;
doc--;
}
}
}
public class VoidPanel
extends JPanel {
public VoidPanel() {
setBackground
(Color.
gray);
}
}
}