-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLecturer.java
More file actions
107 lines (98 loc) · 3.92 KB
/
Copy pathLecturer.java
File metadata and controls
107 lines (98 loc) · 3.92 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
/**
* Write a description of class Lecturer here.
*
* @author (Sabin Karki)
* @version (a version number or a date)
*/
//It is an child class to Teacher and is an hierarchical model
public class Lecturer extends Teacher
{
//Attributes
private String department,grade;
private int yearOfExperience;
private int gradedScore;
private boolean hasGraded;
//Constructor
public Lecturer(int teacherId, String teacherName, String address, String workingType, String employmentStatus,int workingHours, String department, int yearOfExperience)
{
//Calling teacher (parent class or super class)
super(teacherId, teacherName, address, workingType, employmentStatus);
this.setWorkingHours(workingHours);
this.department= department;
this.yearOfExperience= yearOfExperience;
this.gradedScore= 0; //Assigning Default Value
this.hasGraded= false; //Assigning 'false' as told in scenario
}
//Accessor Method
public String getDepartment(){
return this.department;
}
public int getYearOfExperience(){
return this.yearOfExperience;
}
public int getGradedScore(){
return this.gradedScore;
}
public boolean getHasGraded(){
return this.hasGraded;
}
public String getGrade(){
return this.grade;
}
//Mutator Method
public void setGradedScore(int gradedScore){
this.gradedScore= gradedScore;
}
//gradeAssignment Method
public void gradeAssignment(int gradedScore, String department, int yearOfExperience){
//Checking whether Assignment is checked or not
if(this.hasGraded){
System.out.println("The assignment has already been graded.");
}
//In case of not grading, operationg steps
if(yearOfExperience>=5 && getDepartment()==this.department)
{
//Finding which grade has student achieved
if (gradedScore >= 70 && gradedScore <= 100) {
this.grade = "Grade A has been secured";
} else if (gradedScore >= 60) {
this.grade = "Grade B has been secured";
} else if (gradedScore >= 50) {
this.grade = "Grade C has been secured";
} else if (gradedScore >= 40) {
this.grade = "Grade D has been secured";
} else if (gradedScore < 40) {
this.grade = "Grade E has been secured";
} else {
this.grade = "Input correct graded score in it.";
}
System.out.println(getGrade());
this.hasGraded= true;//As in scenario it is changed to 'true' to not be graded again
}else{
//In case of not meeting requirements as above
System.out.println("The above requirement hasn't been met.");
}
}
//Display Method
public void display(){
//Calling display method in Teacher class
System.out.println("Teacher ID: "+this.getTeacherId());
System.out.println("Teacher Name: "+this.getTeacherName());
System.out.println("Teacher Address: "+this.getAddress());
System.out.println("Teacher Working Type: "+this.getWorkingType());
System.out.println("Teacher Employment Status: "+this.getEmploymentStatus());
//Applying condition
System.out.println("Teacher Working Hours: " + (getWorkingHours() > 0 ? this.getWorkingHours() : "null"));
//We could also use 'super.display()' for calling display method in Teacher class as it shortens the method but still the method could be considered method overiding
//Displaying the values of Lecturer class
System.out.println("Department: "+this.getDepartment());
System.out.println("Year of Experience: "+this.getYearOfExperience());
System.out.println("Graded Score: "+this.getGradedScore());
//Checking whether the Assignments has been graded or not and Displaying the values
if(hasGraded){
System.out.println("Graded: "+this.getHasGraded());
}else{
System.out.println("Assignment hasnt been graded yet.");
}
}
}