0% found this document useful (0 votes)
142 views32 pages

Module Code & Module Title CS4001NI Programming Assessment Weightage & Type Coursework One 2019 2018-19 Spring

The document contains pseudocode for three classes: Teacher, Lecturer, and Tutor. The Teacher class stores information about a teacher's subject, name, interviews conducted, and classes per day. The Lecturer class extends Teacher and includes additional details like salary, work hours, appointment date. It has methods for getting, setting, and displaying lecturer information. The Tutor class stores a tutor's salary, dates, qualifications, and the person who appointed them. It contains getter and setter methods as well as a constructor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views32 pages

Module Code & Module Title CS4001NI Programming Assessment Weightage & Type Coursework One 2019 2018-19 Spring

The document contains pseudocode for three classes: Teacher, Lecturer, and Tutor. The Teacher class stores information about a teacher's subject, name, interviews conducted, and classes per day. The Lecturer class extends Teacher and includes additional details like salary, work hours, appointment date. It has methods for getting, setting, and displaying lecturer information. The Tutor class stores a tutor's salary, dates, qualifications, and the person who appointed them. It contains getter and setter methods as well as a constructor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Module Code & Module Title

CS4001NI Programming
Assessment Weightage & Type
Coursework One 2019
2018-19 Spring

Student Name: Basant Bhatta


London Met ID: 18030969
College ID: NP01NT4S190055
Assignment Due Date: 05/10/2019
Assignment Submission Date: 05/10/2019
Word Count: 2359

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

a. Class Name (Teacher):


Teacher
Instance Variables:
-SubjectName: String
-TeacherName: String
-ClassPerDay: String
-InterviewerName: Integer
Methods:
+getSubjectName (): String
+geteacherName (): String
+getClassPerDay (): Integer
+getInterviewerName (): String
+display (): Void
+display:- void

Table 1: Class Diagram of Teacher Class

b. Class Name (Lecturer)


Lecturer
Instance Variables:
-salary: integer
-startingFrom: String
-academicBlockNumber: String
-dailyWorkingHour: integer
-advanceSalary: integer
-joined: Boolean
-terminated: Boolean
Methods:
+getSalary(): Integer
+getStartingFrom(): String
+Lecturer(Subject: String, interviewerName: String, Salary: Integer,
DailyWorkingHour: Integer, ClassPerDay: Integer
+getDailyWorkingHour(): Integer
+getacademicBlockNumber(): String
+get Joined(): Boolean
+getTerminated(): Boolean
+getadvanceSalary(): Integer
+lecturerappointment(lecturerName: String, advancesSalary: Integer,
academicBlockNumber: String, startingFrom: string): Void
+Display(): Void
Table 2: Class Diagram of Lecturer Class

4
Basant Bhatta CS4001NI

c. Class Name (Tutor)

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

CALL String getSubjectName()


DO
RETURN
END DO
CALL String getInterviewerName()
DO
RETURN
END DO
CALL int getTeacherName()
DO
RETURN
END DO
CALL String getClassesPerDay()
DO
RETURN
END DO
CALL set TeacherName(string TeacherName)
DO
this.TeacherName = TeacherName

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

The pseudocode for Class Lecture


CALL Lecturer
DO
this.salary=salary
this.dailyWorkingHour=dailyWorkingHour
academicBlockNumber= “ “
startingFrom= “ “
advanceSalary= 0
terminated= false
joined= false
END DO
CALL int getSalary()

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

Pseudocode for class tutor


CALL Tutor (String Subject, String InterviewerName, int ClassPerDay,int salary,String
appointedBy,String terminationDate)
DO
this.salary=salary
this.appointedBy=appointedBy
this.terminationDate=terminationDate
appointedDate= “ “
evaluationPeriod= “ “
qualification= “ “
joined=false
END DO

CALL int getSalary()

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

CALL setSalary(int newSalary)


DO
IF(Joined==false)
DO
this.salary=salary
END DO
ELSE
DO
OUTPUT (“Tutor is already joined so, It is not possible to
change the salary”)

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

getDailyWorkingHour: Return dailyWorkingHour by parsing it to integer.


getJoined: The above method is used to return the value of joined from the user.
getAdvanceSalary: Return advanceSalary by parsing it to integer.
setDailyWorkingHour: The above method is used to set the value of
dailyWorkingHour from the user as newdailyWorkingHour.
setSalary: Set salary to salary parameter.

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.

getAppointedDate: Return appointedDate by parsing it to String.


getTermnationDate: The above method is used to return the value of
terminationDate from the user.
getQualification: Return qualification by parsing it to String
getAppointedBy: The above method is used to return the value of appointedBy
from the user.
setSalary: Tha above method is used to set the value of salary from the user.
getJoined: Return joined by parsing it to Boolean.
Display: The method is used to display the detail of the Tutor class.

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

Fig: Creating object for teacher class

15
Basant Bhatta CS4001NI

Fig : Inspecting the object created

Fig: Re-inspecting

b. Test 2
Test on class lecture

16
Basant Bhatta CS4001NI

Objective To set the values for class teacher


Action Constructor is called and then
object is inspected, again method
is called and object is re-inspected

Expected Result Object will be created and values


will be assigned.
Actual Result Object is created and values are
assigned.
Conclusion The test was successful.

Fig: Creating object for lecture class

17
Basant Bhatta CS4001NI

Fig: Inspecting the object created

c. Test 3
Test on class Tutor

Objective To set the value for class tutor


Action Constructor is called and then
object is inspected, again method
is called and object is re-
inspected

Expected Result Object will be created and values


will be assigned.
Actual Result Object is created and values are
assigned.
Conclusion The test was successful.

18
Basant Bhatta CS4001NI

Fig: Creating object for Tutor Class

19
Basant Bhatta CS4001NI

Fig: Inspecting the object created

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:

Fig : Syntax Error

Fig: Solution of syntax error

Semantic error:

Fig: Semantic error

21
Basant Bhatta CS4001NI

Fig: solution of semantic error

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

//Declaring constructor and passing parameters


public Teacher(String Subject,String InterviewerName,int ClassPerDay){
this.Subject=Subject;
this.InterviewerName=InterviewerName;
this.ClassPerDay=ClassPerDay;

22
Basant Bhatta CS4001NI

TeacherName=" ";//assigning TeacherName as an empty


}
//accessor method for Subject
public String getSubject(){
return Subject;
}
//accessor method for InterviewerName
public String getInterviewerName(){
return InterviewerName;
}
//accessor method for ClassPerDay
public int getClassPerDay(){
return ClassPerDay;
}
//accessor method for Teachername
public String getTeacherName(){
return TeacherName;
}

//Creating new value for TeacherName


public void setTeacherName(String TeacherName){
this.TeacherName=TeacherName;
}

//Method to display output


public void display(){
System.out.println("Subject :"+getSubject());
System.out.println("Class per day :"+getClassPerDay());

23
Basant Bhatta CS4001NI

System.out.println("Interviewer name ;"+getInterviewerName());


if(!getTeacherName().equals(" ")){
System.out.println("Teacher's name :"+getTeacherName());
}
}
}

b. Codes for class lecture:


/*
* @author(Basant Bhatta)
* @version(4/23/2019)
*/
public class Lecturer extends Teacher{// Lecturer is the sub class of Teacher class
//assigning attributes
private int salary;
private String startingFrom;
private String academicBlockNumber;
private int dailyWorkingHour;
private int advanceSalary;
private boolean joined;
private boolean terminated;

//Declaring constructor and passing parameters


public Lecturer(String Subject,String InterviewerName,int ClassPerDay,int salary,int
dailyWorkingHour){
super(Subject,InterviewerName,ClassPerDay);
this.salary=salary;

24
Basant Bhatta CS4001NI

this.dailyWorkingHour=dailyWorkingHour;
startingFrom=" ";
academicBlockNumber=" ";
advanceSalary=0;
joined=false;
terminated=false;
}

//accessor method for salary


public int getsalary(){
return salary;
}
//accessor method for startingFrom
public String getstartingFrom(){
return startingFrom;
}
//accessor method for academicBlockNumber
public String getacademicBlockNumber(){
return academicBlockNumber;
}
//accessor method for dailyWorkingHour
public int getdailyWorkingHour(){
return dailyWorkingHour;
}
//accessor method for advanceSalary
public int getadvanceSalary(){
return advanceSalary;
}

25
Basant Bhatta CS4001NI

//accessor method for joined


public boolean getjoined(){
return joined;
}
//accessor method for terminated
public boolean getterminated(){
return terminated;
}
/*creating new value for salary
* accessor method for salary
*/
public void setsalary(int salary){
this.salary=salary;
}
/*creating new value for dailyWorkingHour
* accessor method for dailyWorkingHour
*/
public void setdailyWorkingHour(int dailyWorkingHour){
this.dailyWorkingHour=dailyWorkingHour;
}
//method to appoint lecturer for the particular subject
//creating new value for lecturer appointment and passing parameter
public void lecturerAppointment(String lectureName,String startingFrom,int
advanceSalary,String academicBlockNumber){
if (joined==true){
System.out.println("The lecturer name
is:"+getTeacherName());//Interviewername or teachername?
System.out.println("The academic block number
is:"+getacademicBlockNumber());

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?
}
}
}

c. Codes for class tutor:


/*
* It is the subclass(Tutor) of the parent class(Teacher)
* @author Basant Bhatta
* @version 4/23/2019
*/
public class Tutor extends Teacher{
//assigning attributes
private int salary;
private String appointedDate;
private String evaluationPeriod;

28
Basant Bhatta CS4001NI

private String terminationDate;


private String qualification;
private String appointedBy;
private boolean joined;
/* providing corresponding parameter values and empty value to attributes
* declaring constructor and passing parameters
*/
public Tutor(String Subject,String InterviewerName,int ClassPerDay,int salary,String
appointedBy,String terminationDate){
super(Subject,InterviewerName,ClassPerDay);
this.salary=salary;
this.appointedBy=appointedBy;
this.terminationDate=terminationDate;
appointedDate=" ";
evaluationPeriod=" ";
qualification=" ";
joined=false;
}
//accessor method for salary
public int getsalary(){
return salary;
}
//accessor method for appointedDate
public String getappointedDate(){
return appointedDate;
}
//accessor method for evaluationPeriod
public String getevaluationPeriod(){
return evaluationPeriod;
29
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

//method for appoint tutor for the particular platform


// creating new value for tutor appointment and passing parameters
public void tutorAppointment(String tutorName,String appointedDate,String
terminationDate,String qualification){
this.appointedDate=appointedDate;
this.terminationDate=terminationDate;
this.qualification=qualification;
if (joined==false){
super.setTeacherName(tutorName);
joined=true;
}
else{
System.out.println("The tutor is already appointed in:"+getappointedDate());
}
}
//method to display the details of the tutor
public void display(){
super.display();
if (joined==true){
System.out.println("The appointed date is:"+getappointedDate());
System.out.println("The tutor name is :"+super.getTeacherName());
System.out.println("The evaluation period is :"+getevaluationPeriod());
System.out.println("The termination date is:"+getterminationDate());
System.out.println("The tutor salary is:"+getsalary());
System.out.println("The tutor qualification is:"+getqualification());
System.out.println("The tutor is appointed by:"+getappointedBy());
}
}
}

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

You might also like