-
Notifications
You must be signed in to change notification settings - Fork 1
/
ListOfPapers.java
81 lines (66 loc) · 2.1 KB
/
ListOfPapers.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.io.Serializable;
import java.util.Vector;
public class ListOfPapers extends QuestionPaper implements Serializable {
private static final long serialVersionUID = 1L;
private Vector<QuestionPaper> setOfPapers = new Vector<QuestionPaper>();
// Default Constructor
public ListOfPapers() {
}
// To print Names of all Question Papers
@Override
public String toString() {
StringBuffer str = new StringBuffer("");
for (int i = 0; i < setOfPapers.size(); i++) {
str.append("Paper " + (i + 1) + ": " + setOfPapers.get(i).getQuestionPaperName() + "\n");
}
return str.toString();
}
// to print total number of Question Papers
int getCountOfPapers() {
return setOfPapers.size();
}
// add multiple Papers
void addPapers(ListOfPapers examPapers) {
for (QuestionPaper examPaper : examPapers.setOfPapers) {
setOfPapers.add(examPaper);
}
}
// add Paper as an Object
void addPaper(QuestionPaper examPaper) {
setOfPapers.add(examPaper);
}
// remove Paper at particular index
void removePaper(int index) {
setOfPapers.remove(index);
}
// to get particular Question Paper
public QuestionPaper getPaper(int index) {
return (setOfPapers.get(index));
}
// to shuffle questions of every paper
private void shufflePapers() {
for (QuestionPaper questionPaper : setOfPapers) {
questionPaper.shufflePaper();
}
}
// reset papers while loading previous changes
protected void resetExamSetterPapers(ListOfPapers examPapers) {
this.setOfPapers = examPapers.setOfPapers;
}
// reset and shuffle clients' papers only while loading previous changes
protected void resetClientPapers(ListOfPapers examPapers) {
examPapers.shufflePapers();
this.setOfPapers = examPapers.setOfPapers;
}
// get different paper for client
ListOfPapers getClientPaper() {
ListOfPapers clientPaper = new ListOfPapers();
for (int i = 0; i < setOfPapers.size(); i++) {
if (setOfPapers.get(i).isActive())
clientPaper.addPaper(setOfPapers.get(i));
}
return clientPaper;
}
public static void main(String[] args) {
}
}