-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedClassesTest2.java
More file actions
186 lines (140 loc) · 3.83 KB
/
Copy pathNestedClassesTest2.java
File metadata and controls
186 lines (140 loc) · 3.83 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package nestedclass;
public class NestedClassesTest2 {
public static void main(String[] args) {
Exam e1 = new Exam("MCQ", "CN", 100);
e1.attempExam(e1.getExamName());
Exam e2 = new Exam("MCQ", "DBMS", 100);
e2.attempExam(e2.getExamName());
Exam e3 = new Exam("MCQ", "OS", 200);
e3.attempExam(e3.getExamName());
System.out.println("=======================");
Exam.Result r1 = new Exam.Result(90, "A", e1.getExamName());
System.out.println("****Subject**** "+r1.getSubject());
System.out.println(" Marks: "+r1.getMarks());
System.out.println(" Grade: "+r1.getGrade());
Exam.Result r2 = new Exam.Result(80, "B", e2.getExamName());
System.out.println("****Subject**** "+r2.getSubject());
System.out.println(" Marks: "+r2.getMarks());
System.out.println(" Grade: "+r2.getGrade());
Exam.Result r3 = new Exam.Result(70, "B+", e3.getExamName());
System.out.println("****Subject**** "+r3.getSubject());
System.out.println(" Marks: "+r3.getMarks());
System.out.println(" Grade: "+r3.getGrade());
}
}
class Exam
{
String type; //MCQ, Theorotical, both
String examName;
int noOfStudentsAppearing;
int marks;
String subjects[] = {"CN", "DBMS", "OS"};
private HallTicket ht = new HallTicket(subjects, "Mansi", "pune" ,101 , 1);
public Exam(String type, String examName, int noOfStudentsAppearing) {
super();
this.type = type;
this.examName = examName;
this.noOfStudentsAppearing = noOfStudentsAppearing;
}
public String getExamName() {
return examName;
}
public void setExamName(String examName) {
this.examName = examName;
}
void attempExam(String s)
{
//System.out.println("attempting the exam.....");
if(ht.getIsIssued() == 1)
{
System.out.println("Yon can appear for the exam "+s);
}
else
{
try
{
throw new HallTicketNotIssuedYetException("Please collect the hall ticket first");
}
catch(HallTicketNotIssuedYetException he)
{
System.out.println(he);
}
}
}
class HallTicket
{
String[] subjectName;
String studentName;
String examCenter;
int rollNo;
int isIssued;
public HallTicket(String[] subjectName, String studentName, String examCenter, int rollNo, int isIssued) {
super();
this.subjectName = subjectName;
this.studentName = studentName;
this.examCenter = examCenter;
this.rollNo = rollNo;
this.isIssued = isIssued;
}
public String[] getSubjectName() {
return subjectName;
}
public void setSubjectName(String[] subjectName) {
this.subjectName = subjectName;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getExamCenter() {
return examCenter;
}
public void setExamCenter(String examCenter) {
this.examCenter = examCenter;
}
public int getRollNo() {
return rollNo;
}
public void setRollNo(int rollNo) {
this.rollNo = rollNo;
}
public int getIsIssued() {
return isIssued;
}
public void setIsIssued(int isIssued) {
this.isIssued = isIssued;
}
}
static class Result
{
int marks;
String grade;
String subject;
public Result(int marks, String grade, String subject) {
super();
this.marks = marks;
this.grade = grade;
this.subject = subject;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
}
}