Module Code & Module Title CS4001NI Programming Assessment Weightage & Type Coursework One 2019 2018-19 Spring
Module Code & Module Title CS4001NI Programming Assessment Weightage & Type Coursework One 2019 2018-19 Spring
CS4001NI Programming
Assessment Weightage & Type
Coursework One 2019
2018-19 Spring
I confirm that I understand my coursework needs to be submitted online via Google Classroom 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.
1
Basant Bhatta CS4001NI
Contents
1. Introduction:- ............................................................................................................ 3
2. Class Diagram.................................................................................................... 4
a. Class Name (Teacher): ............................................................................................... 4
b. Class Name (Lecturer) ................................................................................................ 4
c. Class Name (Tutor) ..................................................................................................... 5
3. Pseudocode ............................................................................................................. 6
4. Method Description ................................................................................................ 13
5. Testing ................................................................................................................... 14
6. Codes:.................................................................................................................... 22
7. Conclusion ............................................................................................................. 32
2
Basant Bhatta CS4001NI
1. Introduction:-
I am the student of Networking was assigned to do coursework of the
module “Programming”. The coursework has been focused mainly to understand the
concepts of Programming. This project is created on software named “Blue J”. The
coursework has been done in a simple manner so that everyone can easily understand
it. The purpose of this coursework is to write the code according to the guide provided
by module leader. Doing this code we can make the data organized in a better way. So,
doing this program is more reliable.
Doing this task was not easy task. As the main purpose of this coursework is to carry all
the given work within the given date, finishing all the task in the best way, was the
objective of this coursework.
I have done many researches regarding the problems. I have tried my best to do the
coursework in very good manner. The coursework gave me chance to interact with
teachers and many friends. I got the opportunity to obtain various knowledge by sharing
ideas and information regarding the coursework. I express my gratitude to regarded
module leader and my brother for the suggestion.
3
Basant Bhatta CS4001NI
2. Class Diagram
4
Basant Bhatta CS4001NI
Tutor
Instance Variable:
-salary : integer
-appointedDate: String
-evaluationPeriod: String
-terminatedDate: String
-qualification: String
-appointedby: String
-joined: Boolean
Methods:
+tutor(Subject:String,InterviewerName:String,ClassPerDay:int,
salary:int, appontedBy:String,terminationDate:String)
+getSalary () : int
+getAppointedDate () : String
+getEvaluationDate () : String
+getTerminatedDate () : String
+getQualification () : String
+getAppointedBy () : String
+getJoined () : boolean
+setsalary() :int
Table 3: Class Diagram of Tutor Class
5
Basant Bhatta CS4001NI
3. Pseudocode
The pseudocode for class Teacher:
CALL Teacher
DO
this.Subject = Subject
this.InterviewerName = InterviewerName
this.ClassPerDay = ClassPerDay
TeacherName = “ “
END DO
6
Basant Bhatta CS4001NI
END DO
CALL Display()
DO
Output(subjectName)
Output(interviewerName)
Output(classesPerDay)
END DO
If(teacherName. Is equals(“ “))
DO
OUTPUT(“ “)
END DO
ELSE
DO
OUTPUT(teacherName)
END DO
7
Basant Bhatta CS4001NI
DO
RETURN
END DO
CALL String getStartingFrom
DO
RETURN
END DO
CALL String getAcademicBlockNumber()
DO
RETURN
END DO
CALL int dailyWorkingHour()
DO
RETURN
END DO
CALL int advanceSalary()
DO
RETURN
END DO
CALL getJoined()
DO
RETURN
END DO
CALL Boolean getTerminated()
DO
RETURN
END DO
CALL setSalary(int newSalary)
8
Basant Bhatta CS4001NI
DO
this.salary=newSalary
END DO
CALL setDailyWorkingHour(int dailyWorkingHour)
DO
this.dailyWorkingHour=dailyWorkingHour
END DO
CALL lectureAppointment(String lectureName, int advanceSalary, String startingFrom,
String academicBlockNumber)
DO
If(Joined==true)
DO
Output(LectureName)
Output(academicBlockNumber)
ELSE
DO
Super.setteacherName(LectureName)
this.StartingFrom=StartingFrom
this.academicBlockNumber=academicBlockNumber
this.advanceSalary=advanceSalary
END DO
END DO
CALL termination()
DO
If(terminated==0)
OUTPUT(The Lecture has been terminated)
END DO
ELSE
DO
9
Basant Bhatta CS4001NI
Super.setteacherName(“ “)
this.startingFrom=” “
this.advanceSalary= 0
joined= false
terminated= true
END DO
CALL Display()
DO
Super.display()
If(joined== true)
DO
Display(“Termination status:” +terminated)
Display(“StartingFrom:” +getStartingFrom())
Display(“The advanceSalary is:” +getadvanceSalary())
Display(“The lecturerName is:” +getTeacherName())
END DO
END DO
10
Basant Bhatta CS4001NI
DO
RETURN
END DO
CALL get startingFrom()
DO
RETURN
END DO
CALL getacademicBlockNumber()
DO
RETURN
END DO
CALL getadvanceSalary()
DO
RETURN
END DO
CALL getdailyWorkingHour()
DO
RETURN
END DO
CALL getTerminated()
DO
RETURN
END DO
CALL getJoined()
DO
RETURN
END DO
11
Basant Bhatta CS4001NI
END DO
END DO
CALL Tutor(String appointedDate, String tutorName, String terminationDate)
DO
IF(joined==true)
Super.setteacherName(tutorName)
Joined=true
END DO
ELSE
DO
Display(appointedBy)
this.appointedDate=appointedDate
this.qualification=qualification
this.terminationDate=terminationDate
END DO
CALL Display()
DO
Super.display
12
Basant Bhatta CS4001NI
END DO
DO
IF(joined==true)
Display(appointedDate)
Display(appointedBy)
Display(developerName)
Display(terminationDate)
Display(evaluationDate)
Display(qualification)
END DO
4. Method Description
a. Teacher Class:
getSubjectName: return subject by parsing it to string
getTeacherName: The above method is used to return the value of teacherName from
the user.
getClassesPerDay: Return ClassesPerDay by parsing it to integer
getInterviewerName: The above method is used to return the value of
interviewerName from the user.
Display: It displays the output and keep it in array list.
setTeacherName: The above method is used to set the teacherName.
b. Lecture Class:
getSalary: The above method is used to return the value of salary from the user.
getAcademicBlockNumber: Retiurn academicBlockNumber by parsing it to String
getStartingFrom: The above method is used to return the value of StartingFrom from
the user.
13
Basant Bhatta CS4001NI
c. Tutor Class:
getSalary: The above method is used to return the value of salary from
user.
getEvaluationPeriod: Return evaluationPeriod by parsing it to String.
5. Testing
a. Test 1
Test on class Teacher
Objective To set the values for class teacher
Action Constructer is called and action is
14
Basant Bhatta CS4001NI
inspected.
Again method is called and object is
re-inspected.
Expected Result Methods must take value by calling
them. After that object must be
created.
Actual Result Object was created and values were
assigned.
Conclusion Test was Successful
15
Basant Bhatta CS4001NI
Fig: Re-inspecting
b. Test 2
Test on class lecture
16
Basant Bhatta CS4001NI
17
Basant Bhatta CS4001NI
c. Test 3
Test on class Tutor
18
Basant Bhatta CS4001NI
19
Basant Bhatta CS4001NI
20
Basant Bhatta CS4001NI
Errors: An error is a term used to describe any issue that arises unexpectedly that
cause a computer to not function properly.
Syntax Error : These errors are errors which prevents the code from compiling
because of error in the syntax such as missing a semicolon at the end of a statement or
due to missing braces, class not found, etc.
Example:
Semantic error:
21
Basant Bhatta CS4001NI
6. Codes:
a. Codes for class teacher:
/*
* @author(Basant Bhatta)
* @version(4/23/2019)
*
*/
public class Teacher{
// assigning attributes
public String Subject; //representing Subject as String type
public String TeacherName;//representing TeacherName as String type
public String InterviewerName;//representing InterviewerName as String type
public int ClassPerDay;//representing ClassPerDays integer type
22
Basant Bhatta CS4001NI
23
Basant Bhatta CS4001NI
24
Basant Bhatta CS4001NI
this.dailyWorkingHour=dailyWorkingHour;
startingFrom=" ";
academicBlockNumber=" ";
advanceSalary=0;
joined=false;
terminated=false;
}
25
Basant Bhatta CS4001NI
26
Basant Bhatta CS4001NI
}
else{
super.setTeacherName(lectureName);//calling method from parent class.
this.startingFrom=startingFrom;
this.academicBlockNumber=academicBlockNumber;
this.advanceSalary=advanceSalary;
joined=true;
terminated=false;
}
}
//method for lecture termination
public void termination(){
if (terminated==true){
System.out.println("The lecture has been terminated.");
}
else{
super.setTeacherName("");
startingFrom="";
advanceSalary=0;
joined=false;
terminated=true;
}
}
//method to print subject,lecture and salary
public void printingSubjectLectureSalary(){
super.getSubject();
super.getTeacherName();
27
Basant Bhatta CS4001NI
this.getsalary();
System.out.println("The Subject name is:"+Subject);
System.out.println("The Lecturer name is:"+TeacherName);
System.out.println("The salary is:"+salary);
}
//method to display the details of the lecturer
public void display(){
super.display();
if (joined==true){
System.out.println("Termination status:"+terminated);
System.out.println("Starting from:"+getstartingFrom());
System.out.println("The advance Salary is:"+getadvanceSalary());
System.out.println("The lecturer name is:"+getTeacherName());//inside ""
lecturer name or teachername?
}
}
}
28
Basant Bhatta CS4001NI
}
//accessor method for terminationDate
public String getterminationDate(){
return terminationDate;
}
//accessor method for qualification
public String getqualification(){
return qualification;
}
//accessor method for appointedBy
public String getappointedBy(){
return appointedBy;
}
//accessor method for joined
public boolean getjoined(){
return joined;
}
/*creating new value for salary
* accessor method for salary
*/
public void setsalary(int salary){
if(joined==false){
this.salary=salary;
}
else{
System.out.println("Tutor is already joined so,It is not possible to change the
salary");
}
}
30
Basant Bhatta CS4001NI
31
Basant Bhatta CS4001NI
7. Conclusion
The coursework given to us was very tough. After I completed this coursework I have
learned many things which was included in coursework. There is a parent class Teacher
which has four attributes and two other sub-classes Lecturer and Tutor of parent class
according to the coursework. By using the software called BlueJ we need to develop the
program.
Task given to us is not easy. It took lot of time to understand the question given and
lot of research is needed for doing this task. At the beginning we create the
pseudocode and the program was developed. With the help of that pseudocode for
each method that helped to find any error while writing program. Program is
successful if there is no error found.
I faced a lot of problems which was so irritating to research about it but because of my
interest in programming I didn’t give up. I consult with my teachers and friends for better
ideas and techniques about how to do this task. And because of this I completed my
coursework successfully.
32