-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudents.java
More file actions
60 lines (47 loc) · 2 KB
/
Students.java
File metadata and controls
60 lines (47 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.sql.SQLOutput;
import java.util.Random;
import java.util.Vector;
public class Students extends Thread {
public static Random rand = new Random();
double number1,number2;
private int numStudents;
public Students(int i){
super("Student-" + i);
this.numStudents = i;
}
public void run(){
synchronized (this) {
number1 = rand.nextDouble();
if (number1 > 0.15) { //85% student submit the questionnaire
msg(this.getName() + " has submitted the health questionnaire.");
Project1.isSubmit = true;
Project1.m.getInLineQ(this);
if(Project1.m.found){
msg(this.getName() + " go to nurse room.");
Project1.m.studentGoToNurseRoom(this);
if(Project1.m.isPostive){
msg(this.getName() + " test is positive and send to go home");
if(Project1.m.max == 3){
msg("everybody go home.");
}
}else {
// student test negative and go to class room
msg(this.getName() + " test is negative and go to classroom.");
Project1.m.studentGoToClassroom(this);
}
}
else{
msg(this.getName() + " go to classroom");
Project1.m.studentGoToClassroom(this);
}
} else { //15% student forgot to submit the questionnaire.
msg(this.getName() + " has not submitted the health questionnaire.");
Project1.isSubmit = false;
Project1.m.getInLineQ(this);
}
}
}
void msg(String s) {
System.out.println("[" + (System.currentTimeMillis() - Project1.time) + "]: " + s);
}
}