-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.java
More file actions
263 lines (185 loc) · 5.22 KB
/
Copy pathproject.java
File metadata and controls
263 lines (185 loc) · 5.22 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import java.util.ArrayList;
import java.util.List;
class Person{
private int Id;
private String Name;
Person( int Id, String Name){
this.Id=Id;
this.Name=Name;
}
public String getName(){
return Name;
}
public int getId(){
return Id;
}
public String toString() {
return "Id : "+Id+ " name :"+Name;
}
}
class School {
static String schoolName = "Allied School(Shahrah-e-Faisal) Campus ";
private List<Teacher> teachers;
private List<Student> students;
private static int totalMoneyEarned;
private static int totalMoneySpent;
public School(List<Teacher> teachers, List<Student> students) {
this.teachers = teachers;
this.students = students;
totalMoneyEarned=0;
totalMoneySpent=0;
}
public List<Teacher> getTeachers() {
return teachers;
}
public void addTeacher(Teacher teacher) {
teachers.add(teacher);
}
public List<Student> getStudents() {
return students;
}
public void addStudent(Student student) {
students.add(student);
}
public int getTotalMoneyEarned() {
return totalMoneyEarned;
}
public static void updateTotalMoneyEarned(int MoneyEarned) {
totalMoneyEarned += MoneyEarned;
}
public int getTotalMoneySpent() {
return totalMoneySpent;
}
public static void updateTotalMoneySpent(int moneySpent) {
totalMoneyEarned-=moneySpent;
}
}
class Student extends Person{
private int grade;
private int feesPaid;
private int feesTotal;
Student h;
public Student(int Id,String Name,int grade){
super(Id,Name);
this.feesPaid=0;
this.feesTotal=30000;
this.grade=grade;
}
public void setGrade(int grade){
this.grade=grade;
}
public void payFees(int fees){
feesPaid+=fees;
School.updateTotalMoneyEarned(feesPaid);
}
public int getGrade() {
return grade;
}
public int getFeesPaid() {
return feesPaid;
}
public int getFeesTotal() {
return feesTotal;
}
public int getRemainingFees(){
return feesTotal-feesPaid;
}
public void logon(SwipeCard s){
s.Swipe(h);
}
@Override
public String toString() {
super.toString();
return
" Total fees paid so far $"+ feesPaid;
}
}
class Teacher extends Person{
private int salary;
private int salaryEarned;
Teacher t;
public Teacher(int Id, String Name, int salary){
super(Id,Name);
this.salary=salary;
this.salaryEarned=0;
}
public int getSalary(){
return salary;
}
public void setSalary(int salary){
this.salary=salary;
}
public void receiveSalary(int salary){
salaryEarned+=salary;
School.updateTotalMoneySpent(salary);
}
public void logon(SwipeCard s){
s.Swipe(t);
}
@Override
public String toString() {
super.toString();
return " Total salary earned so far $"
+ salaryEarned;
}
}
class SwipeCard
{
private String madeofCard;
public SwipeCard(){};
public SwipeCard(String madeofCard)
{
this.madeofCard = madeofCard;
}
public String getMakeofCard(){
return madeofCard;
}
public void Swipe(Teacher teacher){
System.out.println("Swipe the teacher");
}
public void Swipe(Student student){
System.out.println("Swipe the student");
}
}
class Test{
public static void main(String[] args)
{
Teacher amjad = new Teacher(1,"Amjad",500);
Teacher ahmed = new Teacher(2,"Ahmed",700);
Teacher laiba = new Teacher(3,"Laiba",600);
List<Teacher> teacherList = new ArrayList<>();
teacherList.add(amjad);
teacherList.add(ahmed);
teacherList.add(laiba);
Student ashraf = new Student(1,"Ashraf",4);
Student suleman = new Student(2,"Suleman",12);
Student rabbi = new Student(3,"Rabbi",5);
List<Student> studentList = new ArrayList<>();
studentList.add(ashraf);
studentList.add(suleman);
studentList.add(rabbi);
School ghs = new School(teacherList,studentList);
Teacher megan = new Teacher(6,"Megan", 900);
Student usama = new Student(1,"Usama", 8);
ghs.addTeacher(megan);
rabbi.payFees(5000);
suleman.payFees(6000);
System.out.println(ghs.schoolName);
System.out.println("GHS has earned $"+ ghs.getTotalMoneyEarned());
System.out.println("------Making SCHOOL PAY SALARY----");
ahmed.receiveSalary(ahmed.getSalary());
System.out.println("GHS has spent for salary to " + ahmed.getName()
+" and now has $" + ghs.getTotalMoneyEarned());
amjad.receiveSalary(amjad.getSalary());
System.out.println("GHS has spent for salary to " + amjad.getName()
+" and now has $" + ghs.getTotalMoneyEarned());
System.out.println(laiba);
laiba.receiveSalary(laiba.getSalary());
System.out.println(laiba);
System.out.println("------Student report----");
System.out.printf("best student : %s \n " , ashraf.getName());
SwipeCard s = new SwipeCard("C25896");
megan.logon(s);
usama.logon(s);
}
}