Preyanka Giri
Preyanka Giri
CS4001NI Programming
2023-24 Autumn
I confirm that I understand my coursework needs to be submitted online via MySecondTeacher under the
relevant module page before the deadline in order for my assignment to be accepted and marked. I am
fully aware that late submissions will be treated as non-submission and a marks of zero will be awarded.
Programming CS4001NI
Table of Contents
1. Introduction ............................................................................................. 1
2. Class Diagram ........................................................................................ 2
2.1. Class diagram of parent class (Teacher)........................................... 2
2.2. Class diagram of child class (Lecturer) ............................................. 3
2.3. Class diagram of child class(Tutor) ................................................... 4
2.4. Inherited class diagram ..................................................................... 5
3. Pseudocode ............................................................................................ 6
3.1. Pseudocode of Teacher class ........................................................... 6
3.2. Pseudocode of Lecturer class ........................................................... 8
3.3 . Pseudocode of Tutor class............................................................. 11
4. Method Description ............................................................................... 15
4.2. Method description of lecturer ......................................................... 16
4.3. Method description of Tutor ............................................................ 17
5. Test....................................................................................................... 18
5.1. Test 1.............................................................................................. 18
5.2. Test 2.............................................................................................. 22
In this test, the Tutor class was inspected, salary was set and the Tutor
class was reinspected ............................................................................ 22
5.3. Test 3.............................................................................................. 29
5.4. Test 4.............................................................................................. 31
6. Error Detection and Correction ............................................................. 34
6.1. Syntax error .................................................................................... 34
6.2. Semantic Error ................................................................................... 37
.............................................................................................................. 38
6.3. Logical Error ...................................................................................... 39
7. Conclusion ............................................................................................ 41
8. Appendix............................................................................................... 42
8.1. Teacher .......................................................................................... 42
Programming CS4001NI
1. Introduction
Welcome to this advanced Java programming course, where the key idea of
inheritance will be the main emphasis. In this lesson, a class hierarchy is
introduced, consisting of two specialized child classes, "Tutor" and
"Lecturer," and a parent class, "Teacher."
A key component of effectively modelling connections is inheritance. The
"Teacher" class serves as the cornerstone, containing common
characteristics and actions for a cohesive codebase. We place a strong
emphasis on best practices for creating a scalable and modular class
hierarchy throughout the whole course to improve code reuse and
maintainability.
We will investigate the development of two specialized child classes,
"Lecturer" and "Tutor," each suited to a different position in the classroom.
See how inheritance and polymorphism may be used to create a codebase
that is both resilient and flexible. Come along on this adventure to improve
your Java programming abilities by fusing theory with real-world application
to ensure project success.
Fig 1 classes 1
1
Programming CS4001NI
2. Class Diagram
Class diagrams are used to show links between the objects in a framework.
Classes, variables, and connections are all addressed in the framework
hierarchy and organization charts for courses. A lesson is attended using a
rectangle structure on a class graph, verified with the lesson title,
accompanied by a trait list and a method list.
2
Programming CS4001NI
3
Programming CS4001NI
4
Programming CS4001NI
5
Programming CS4001NI
3. Pseudocode
7
Programming CS4001NI
8
Programming CS4001NI
return this.gradedscore
9
Programming CS4001NI
10
Programming CS4001NI
11
Programming CS4001NI
ELSE
ELSE
12
Programming CS4001NI
END IF
this.salary equals 0
this.performanceindex equals 0
IF iscertified
ELSE
13
Programming CS4001NI
END IF
END display
14
Programming CS4001NI
4. Method Description
15
Programming CS4001NI
16
Programming CS4001NI
Tutor(Child Class)
Tutor(double salary, String This method accepts eleven
specialization, parameters and also initializes
String academicqualifications, attributes in the constructor by
int performanceindex, boolean assigning value as parameter.
iscertified
Int teacherid, String
teachername, String address,
String workingtype,String
employmentstaus, int
workinghours)
getSalary(): This method returns the value of
attribute Salary as double.
getSpecialization(): This method returns the value of
attribute Specialization as String.
getAcademicQualification(): This method returns the value of
attribute
AcademicQualification as String.
getPerformanceIndex(): This method returns the value of
attribute PerformanceIndex as
integer.
getIsCertified(): This method returns the value of
attribute IsCertified as boolean.
setSalaryAndCertidy(double This method accepts parameter of
salary, int performanceindex): Tutor as String and set the value
Void removeTutor(): This method remove a tutor and
display the result.
17
Programming CS4001NI
5. Test
Running a program under test involves looking for faults, mistakes, and
security vulnerabilities. It assists us in making changes to or application and
enhancing the user interface.
5.1. Test 1
Objective To inspect lecturer class, grade the assignment, re-
inspect the lecturer class
Action Call constructor of lecturer class:
teacherid = 23045
teachername = “Ram”
address= “Kathmandu”
workingtype= “Fulltime”
employmentstatus= “Fulltimeemployee”
workinghours= 7
department= “Computing”
yearsOfExperience= 6
In this test, lecturer was inspected before and grade the assignment and
re-inspected
18
Programming CS4001NI
19
Programming CS4001NI
20
Programming CS4001NI
21
Programming CS4001NI
5.2. Test 2
In this test, the Tutor class was inspected, salary was set and the Tutor
class was reinspected
teachername:”Ram”
address:”Kathmandu”
workingtype: “Fulltime”
employmentstatus:
“Fulltimeemployee”
workinghours: 22
salary: 20000:00
specialization: “Maths”
academicqualifications: “Bachelor”
performanceindex: 7
Inspection of Tutor class
Void setsalary is called following
arguments
Salary = 20000.00
Performanceindex = 7
Re-inspection of Tutor class
22
Programming CS4001NI
23
Programming CS4001NI
24
Programming CS4001NI
25
Programming CS4001NI
26
Programming CS4001NI
27
Programming CS4001NI
28
Programming CS4001NI
5.3. Test 3
In this test, the Tutor class was again inspected after removing tutor
29
Programming CS4001NI
30
Programming CS4001NI
5.4. Test 4
31
Programming CS4001NI
32
Programming CS4001NI
33
Programming CS4001NI
34
Programming CS4001NI
35
Programming CS4001NI
36
Programming CS4001NI
37
Programming CS4001NI
38
Programming CS4001NI
39
Programming CS4001NI
40
Programming CS4001NI
7. Conclusion
.
The project defines three classes: Teacher, Tutor, and Lecturer, with each
inheriting from the Teacher class. The Teacher class contains basic
information such as an ID, name, address, working type, employment
status, and working In this project, Java object-oriented programming was
the main focus .The main concept of this project was to use inheritance to
link child and parent classes. There were many methods for creating and
displaying classes, determining valuations for different types of attributes,
etchours. The Tutor class extends Teacher class, adding attributes like
salary, specialization, academic qualifications, performance index, and
certification status. The Lecturer class, which extends Teacher, includes
characteristics unique to lecturers such as department, yearsofexperience,
gradedscore and graded status.
The project includes methods for configuring and retrieving various
properties, as well as methods for grading assignments in the Lecturer
class. Additionally, there are techniques for certifying tutors based on
performance and working hours, as well as removing tutors who are not
certified.
Display methods are used to print out. This course covers object-oriented
programming. This is my first programming course. I began the coursework
by programming the software, then gradually developed my mental
framework and created a basic outline of the assignment. First of all, I was
completely ignorant about pseudo code, mistakes, and inspection. To learn
the material, I used internet resources and lecture lessons. The technique
explanation similarly baffled me .I first struggled a lot with both logical and
semantic issues. As a result, I have issues while viewing the item. I now
fully understand how methods, constructors, attributes, and other concepts
are used. Additionally, because I used Blue J to write my scripts on it, I
have a clear understanding of how to utilize it correctly. Overall, I've
learned a lot from this program, which has helped me advance my
knowledge and abilities.
41
Programming CS4001NI
8. Appendix
8.1. Teacher
//accessor method
//display method
public void display(){
43
Programming CS4001NI
8.2. Lecturer
//getter
public String getDepartment(){
return this.department;//This method returns the value of department
}
public int getYearsofExperience(){
return this.yearsOfExperience;//This method returns the value of
yearsOfExperience
}
public int getGradedscore(){
return this.gradedscore;//This method returns the value of gradedscore
}
public boolean getHasgraded(){
return this.hasgraded;//This method returns the value of hasgraded
44
Programming CS4001NI
}
//setter
//setting the value of attributes**/
public void setGradedscore(int gradedScore){
this.gradedscore = gradedScore;
}
}
else{
System.out.println("Score has not been graded yet");
}
}
super.display();
System.out.println("Department:"+this.getDepartment());
System.out.println("Years of Experience:"+this.getYearsofExperience());
if(hasgraded){
System.out.println("Graded score:"+ this.getGradedscore());
} else{
System.out.println("Assignment not graded yet.");
}
}
}
8.2. Tutor
public class Tutor extends Teacher {
46
Programming CS4001NI
}
//accessor
public double getSalary()
{
return this.salary;
}
this.iscertified = true;
} else {
System.out.println("The salary cannot be approved");
}
}
} else {
System.out.println("Tutor not removed because he/she is certified");
}
}
// Method to display details
public void display() {
super.display(); // display details from parent class
if (!iscertified) {
System.out.println("Tutor not certified. Details not available.");
} else {
System.out.println("Salary: $" + salary);
System.out.println("Specialization: " + specialization);
System.out.println("Academic Qualifications: " +
academicqualifications);
48
Programming CS4001NI
49
Programming CS4001NI
9. Bibliography
50