You are on page 1of 55

Informatics College Pokhara

PROGRAMMING
CS4001NP

Coursework 1

Submitted By: Submitted To:

Name: Anjal Mahato Mr. Sushil Poudel

London Met ID: 20048637 Module leader

Group: C4 Programming

Date: 23rd May


Table of Contents
1. Introduction .......................................................................................................................................... 1
2. Class Diagram ....................................................................................................................................... 2
3. Pseudocode .......................................................................................................................................... 3
3.1 Pseudocode for Super class Course: ............................................................................................ 3
3.2 Pseudocode for child class AcademicCourse ............................................................................... 5
3.3 Pseudocode for NonAcademicCourse ......................................................................................... 8
4. Description of Methods ..................................................................................................................... 12
4.1 Method used in Course class: .................................................................................................... 12
4.2 Method used in Academic course: ............................................................................................ 12
4.3 Method used in NonAcademicCourse: ...................................................................................... 13
5. Testing................................................................................................................................................. 14
5.1 Test 1:.......................................................................................................................................... 14
5.2 Test 2........................................................................................................................................... 18
5.3 Test 3........................................................................................................................................... 22
5.4 Test 4........................................................................................................................................... 25
6. Error and Correction:.......................................................................................................................... 32
6.1 Error 1: Error while calling super class display method: ........................................................... 32
6.2 Correction of calling the super class display method: .............................................................. 32
6.3 Data Type in Error: ..................................................................................................................... 32
6.4 Correction of Data Type Error: ................................................................................................... 33
6.5 Logical Error: ............................................................................................................................... 33
6.6 Correction of Logical Error ......................................................................................................... 35
6.7 Symmetric Error.......................................................................................................................... 36
6.8 Correction of Symmetric Error. .................................................................................................. 37
7. Conclusion ...................................................................................................................................... 38
8. Bibliography........................................................................................................................................ 38
9. Appendix ............................................................................................................................................. 39
9.1 Appendix 1: Course .................................................................................................................... 39
9.2 Appendix 2: AcademicCourse .................................................................................................... 41
9.3 Appendix 3: NonAcademicCourse ............................................................................................. 46
Figure 1 JAVA ................................................................................................................................................ 1
Figure 2 Creating the object of AcademicCourse Class.............................................................................. 15
Figure 3 Input the information of Course duration, course name level, Credit and Number of
assessments 16
Figure 4 Inspecting AcademicCourse Class ......................................................................................... 16
Figure 5 Calling the register method. ............................................................................................... 17
Figure 6 Input the information of CourseLeader, lecturerName, Starting Date and completion Date 17
Figure 7 Re-inspecting Academic Course .............................................................................................. 18
Figure 8 Creating Object for the class NonAcademicCourse ................................................................ 19
Figure 9 Input all the information of Course duration, courseID, coursename and prerequisite ........ 19
Figure 10 Inspect NonAcademicCourse Class ..................................................................................... 20
Figure 11 Calling register method of NonAcademic Course. .............................................................. 20
Figure 12 Input the information of CourseLeader, instructorName, startDate, completionDate,
examDate. 21
Figure 13 Re-inspecting NonAcademicCourse class .......................................................................... 22
Figure 14 Creating the object of NonAcademicCourse Class .............................................................. 23
Figure 15 Input the information of course duration, courseID, coursename and prerequisite. ........ 23
Figure 16 Inspect NonAcademicCourse Class ..................................................................................... 24
Figure 17 Calling void remove method ................................................................................................... 24
Figure 18 Re-inspect NonAcademicCourse Class ................................................................................... 25
Figure 19 Input all the information of duration, courseID, courseName, level, Credit and
NumberofAssessments. .............................................................................................................................. 26
Figure 20 Calling display method of AcademicCourse Class .................................................................. 26
Figure 21 Displaying the information after object creation of AcademicCourse Class ...................... 27
Figure 22 Input the information of CourseLeader, lecturers,startingDate and completionDate of
AcademicCourse Class ................................................................................................................................ 27
Figure 23 Displaying the information after calling register method of AcademicCourse Class ......... 28
Figure 24 Displaying the information after course starting ................................................................ 28
Figure 25 Displaying the information after object creation of NonAcademicCourse Class................ 28
Figure 26 Input the information of CourseLeader, instructorName, startDate, completionDate,
examDate of NonAcademicCourse Class .................................................................................................... 29
Figure 27 Calling void display method of NonAcademicCourse Class ................................................ 29
Figure 28 Displaying the information after calling register method of NonAcademicCourse Class ... 30
Figure 29 Calling remove method of NonAcademicCourse Class .......................................................... 30
Figure 30 Calling display method after calling remove method of NonAcademicCourse Class ............. 31
Figure 31 Displaying the information after calling remove method of NonAcademicCourse Class ...... 31
Figure 32 Error while calling super class display method: ....................................................................... 32
Figure 33 Correction of calling the super class display method: ............................................................ 32
Figure 34 Data Type in Error: .................................................................................................................. 32
Figure 35 Correction of Data Type Error ................................................................................................... 33
Figure 36 Logical Error:............................................................................................................................. 34
Figure 37 Correction of Logical Error .................................................................................................. 36
Figure 38 Symmetric Error ...................................................................................................................... 36
Figure 39 Correction of Symmetric Error. ............................................................................................... 37
Table 1 Testing table ................................................................................................................................... 14
Table 2 Test 1 ........................................................................................................................................... 15
Table 3 Test 2 ........................................................................................................................................... 18
Table 4 Test 3 ............................................................................................................................................. 22
Table 5 Test 4 ........................................................................................................................................... 25
1. Introduction
The main aim of doing this assignment is to create a class to represent Course, along with two
subclasses to represent a AcademicCourse and NonAcademicCourse respectively. We have to
take the help of programming software like BlueJ. In this coursework Course class is the parent
class of AcademicCourse class and NonAcademicCourse class. Hence, AcademicCourse and
NonAcademicCourse is the child class of Course class. In this coursework, there must be use of
inheritance while making subclasses like AcademicCourse and NonAcademicCourse. This project
is done to check the knowledge of the students about the programming and programming
concept.
Java may be a general-purpose, class-based, object-oriented programing language designed for
having lesser implementation dependencies. it's a computing platform for application
development. Java is fast, secure, and reliable, therefore. it's widely used for developing Java
applications in laptops, data centers, game consoles, scientific supercomputers, cell phones, etc.
Java may be a multi-platform, object-oriented, and network-centric language. it's among the
foremost used programing language. Java is additionally used as a computing platform. It is
considered together of the fast, secure, and reliable programming languages preferred by most
organizations to create their projects. (Guru99, 2021)
The Java language was initially called OAK. Originally, it had been developed for handling portable
devices and set-top boxes. Oak was a huge failure. In 1995, Sun changed the name to "Java" and
modified the language to require advantage of the burgeoning www (World Wide Web)
development business. Later, in 2009, Oracle Corporation acquired Sun Microsystems and took
ownership of three key Sun software assets: Java, MySQL, and Solaris. (Guru99, 2021)
Java is used for many purposes. Some of them is given below:

• It is used for developing Android Apps. It helps you to make Enterprise Software.
• It has wide selection of Mobile java applications
• It is a Scientific Computing Applications
• It is used for giant Data Analytics
• it's used for Java Programming of Hardware devices
• it's used for Server-Side Technologies like Apache, JBoss, GlassFish, etc. (Guru99, 2021)

Figure 1 JAVA

1
2. Class Diagram

Course

-courseID: String
-courseName: String
-duration: int
-courseLeader: String

+Course(courseID: String, courseName: String, duration: String)


+getCourseID(): String
+getCourseName():String
+getduration(): int
+getCourseLeader: String
+setCourseLeader(CourseLeader: String): void
+display(): void

AcademicCourse NonAcademicCourse
-LecturerName: String -InstructorName: String
-Level: String -StartDate: String
-Credit:String -CompletionDate: String
-StartingDate: String -ExamDate: String
-CompletionDate: String -prerequisite: String
-NumberOfAssessments: double -isRegistered: boolean
-isRegistered: boolean -isRemoved: boolean

2
+AcademicCourse(duration:int +NonAcademicCourse(courseID:
,courseName: String, duration: int, String, courseName: String, duration:
prerequisite: String): void int, prerequisite: String
+getlecturers(): String +getinstructorName(): String
+getlevel(): String +getduration(): double
+getcredit(): String +getstartDate(): String
+getstartingDate(): String +getcompletionDate(): String
+completionDate(): String +getexamDate(): String
+getnumberOfAssessments(): double +getprerequisite(): String
+getIsRegistered(): boolean +getIsRegistered(): boolean
+setlecturers(): String +getIsRemoved(): boolean
+registerAcademicCourse(CourseLeader:
String, lecturers: String, startingDate:
String, completionDate: String):void
+displayDetailsOfCourse():void

3. Pseudocode

Pseudocode is an off-the-cuff way of programming description that doesn't require any strict
programing language syntax or underlying technology considerations. it's used for creating an
overview or a rough draft of a program.

3.1 Pseudocode for Super class Course:


CALL class Course

CALL String courseID

CALL String courseName

Call int duration

CALL String courseLeader

CALL course (int duration, String courseID, String coursename, String courseLeader)

this.courseID=courseID;

this.courseName=courseName;

3
this.duration=duration;

courseLeader=””

END DO

CALL String getCourseID()

DO return CourseID

END DO

CALL String getCourseName()

DO return CourseName

END DO

CALL int getDuration()

Do return duration

END DO

CALL String getCourseLeader()

DO return courseLeader

END DO

CALL set CourseLeader(String CourseLeader)

DO

this.courseLeader=CourseLeader

END DO

CALL display()

DO

OUTPUT(“The Id of the course is”+getCourseID())

OUTPUT(“The name of the course is “+getCourseName())

OUTPUT(“The time to complete this course is”+getDuration())

IF(StudentName is not null)

DO

OUTPUT(“The name of the courseleader is”+getCourseLeader())

END DO

4
END IF

3.2 Pseudocode for child class AcademicCourse

CALL class AcademicCourse extends Course


CALL private String lecturerName
CALL private String Level
CALL private String Credit
CALL private String StartingDate
CALL private String CompletionDate
CALL private double NumberOfAssessments
CALL private boolean isRegistered
CALL constructor AcademicCourse(int duration, String courseID, String courseName, String
Level, String Credit, double NumberOfAssessments)
DO
super(duration,courseID,courseName)
this.Level= Level
this.Credit=Credit
this.NumberOfAssessments=NumberOfAssessments
this.LecturerName= “”
this.StartingDate=””
this.CompletionDate=””
this.isRegistered=””
END DO
CALL String getlecturers()
DO
Return LecturerName

5
END DO
CALL String getlevel()
DO
Return Level
END DO
CALL String getCredit()
DO
Return Credit
END DO
CALL String getstaringDate()
DO
Return StartingDate
END DO
CALL String getcompletionDate()
DO
Return CompletionDate
END DO
CALL double getnumberOfAssessments()
DO
Return NumberOfAssessments
END DO
CALL boolean getIsRegistered()
DO
Return isRegistered
END DO
CALL setlecturers(String lecturers)
DO

6
LecturerName=lecturers
END DO
CALL setnumberOfAssessments(double numberOfAssessments)
numberOfAssessments= numberOfAssessments
END DO
CALL registerAcademicCourse(String CourseLeader, String lecturers,String startingDate,
String completionDate)
DO
IF(isRegistered==true)
DO
OUTPUT(“The course has been registered and the lecturer name is ” +getlecturers())
OUTPUT(“The starting date of course is ”+getstartingDate() )
OUTPUT(“The completion date of academic course is ”+getcompletionDate())
END DO
ELSE
DO
Super.setCourseLeader(CourseLeader)
LecturerName=lecturers
StartingDate=startingDate
CompletionDate=completionDate
isRegistered=true
END DO
END IF
END DO
CALL display DetailsOfCourse()
DO
super.display()

7
IF(isRegistered==true)
DO
OUTPUT(“Name of the lecturer is ”+getlecturers())
OUTPUT(“Level of academic course is ”+getlevel())
OUTPUT(“Credit of academic course is ”+getcredit())
OUTPUT(“Starting date of academic course is ”+getstartingDate())
OUTPUT(“Completion date of academic course is ”+getcompletionDate())
OUTPUT(“No of assessments is ”+getnumberOfAssessments())
END DO
END

3.3 Pseudocode for NonAcademicCourse

CALL class NonAcademicCourse extends Course


CALL private String InstructorName
CALL private String startDate
CALL private String completionDate
CALL private String prerequisite
CALL private boolean isRegistered
CALL private boolean isRemoved
CALL constructor NonAcademicCourse (int duration, String courseID, String coursename,
String prerequisite)
DO
super(duration, courseID, coursename)
this.prerequisite=prerequisite
this.InstructorName=””
this.StartDate=””
this.completionDate=””

8
this.ExamDate=””
this.isRegistered=””
this.isRemoved=””
END DO
CALL String getinstructorName()
DO
Return InstructorName
END DO
CALL String getstartDate()
DO
Return StartDate
END DO
CALL String getCompletionsDate()
DO
Return completionDate
END DO
CALL String getexamDate()
DO
Return ExamDate
END DO
CALL String getPrerequisite()
DO
Return prerequisite
END DO
CALL boolean getIsRegistered()
DO
Return isRegistered

9
END DO
CALL boolean getIsRemoved()
DO
Return isRemoved
END DO
CALL setinstructorName(String instructorName)
DO
IF(isRegistered==false)
DO
this.InstructorName=instructorName
END DO
ELSE
DO
OUTPUT(“The course is already register”)

END DO

END DO

CALL registerNonAcademicCourse(String CourseLeader, String instructorName, String startDate, String


CompletionsDate, String examDate)

DO

IF(isRegistered==false)

DO

setinstructorName(instructorName)

setCourseLeader(CourseLeader)

isRegistered==true

END DO

ELSE

DO

OUTPUT(“The course is already started from ”+getstartDate())

10
END DO

this.StartDate=startDate

this.completionDate=CompletionsDate

this.ExamDate=examDate;

END DO

CALL remove Course()

DO

IF(isRemoved==true)

DO

OUTPUT(“The course has been removed ”)

END DO

ELSE

DO

setCourseLeader(courseLeader)

this.InstructorName=””

this.StartDate=””

this.completionDate=””

this.ExamDate=””

this.isRegistered=false

this.isRemoved=true

END DO

END DO

CALL displayDetailsOfNonAcademicCourse()

DO

super.display()

IF(isRegistered==true)

DO

OUTPUT(“Name of the instructor ”+getinstructorName())

11
OUTPUT(“Start Date of non academic course is ”+getstartDate())

OUTPUT(“Completion Date of non academic course is ”+getCompletionsDate())

OUTPUT(“Exam Date of non academic course is ”+getexamDate())

END DO

END IF

END

4. Description of Methods
There are two method used in this coursework i.e getter and setter method. Getter method
is also known as the accessor method and Setter method is also known as mutator method.
Beside these two methods, display method is also used. The description of the method used
in this coursework are as follows:

4.1 Method used in Course class:


• getCourseID(): This method is used to return the course id of the courses.
• getCourseName(): This method is used to return the name of the course.
• getDuration(): This method is used to return the duration of the course.
• getCourseLeader(): This method is used to return the leader name of the course.
• Set CourseLeader(String CourseLeader): This method is used to set the course leader
to a new course leader.
• display(): This method is used to print the details of courseID, courseName and
duration attributes.

4.2 Method used in Academic course:


• getlecturers(): This method is used to return the name of the leader of the
academic course.
• getlevel(): This method is used to return the level of the academic course.
• getcredit(): This method is used to return the credit of the academic course.
• getstartingDate(): This method is used to return the date from when academic
course is started.
• getcompletionDate(): This method is used to return the date when the academic
course is complete.
• getnumberOfAssessments(): This method is used to return the number of
assessment used in academic course.

12
• getIsRegistered(): This method is used to return the registration of the academic
course.
• setlecturers(String lecturers): This method is used to set the name of the lecturer
to a new lecturer name.
• setnumberOfAssessments(double numberOfAssessments): This method is used
to set the assessment number to a new assessment number.
• Void registerAcademicCourse(String CourseLeader, String lecturers, String
startingDate, String completionDate): This method takes four parameters. If the
course has joined a suitable message including lecturer name, starting date,
completion date is displayed. If not then it assigns the values of lecturer name,
staring date, completion date. It also changes the isRegistered status to true.
• Void displayDetailsOfCourses(): This method calls the Course class and displays
its details. If isRegistered status is true then it prints the details of the course
including lecturer name, level, credit, starting date, completion date and number
of assessments.

4.3 Method used in NonAcademicCourse:


• getinstructorName(): This accessor method return the name of the instructor
of the non academic course.
• getstartDate(): This accessor method return the start date of the non
academic course.
• getCompletionsDate(): This accessor method return the date of the non
academic course when it was completed.
• getexamDate(): This accessor method return the exam date of the non
academic course.
• getPrerequisite(): This accessor method return the priority condition to study
academic course.
• getIsRegistered(): This accessor method return the registration of the non
academic course.
• getIsRemoved(): This accessor method return the removed non academic
course.
• setinstructorName(String instructorName): This mutator method set the
name of the instructor to a new instructor name.
• void registorNonAcademicCourse(String CourseLeader, String
instructorName, String startDate, String CompletionsDate, String examDate
as parameter): This method takes five parameters. If the non academic course

13
has not registered then instructor name and course leader is set . If not then
suitable message is display.
• Void removeCourse(): This is the remove method. If the isRemoved is true
then suitable message is display. If not then set CourseLeader from the parent
class
• Void display DetailsOfNonAcademicCourse(): If the non academic course is
registered then it is true then instructor name, starting date, completion date,
exam date is displayed.

5. Testing
Testing is the way to detect the error and solve it. Testing in the programming is one of the
important parts of development of the program. Here is the testing of the program of our
coursework:

Tests Objectives
1 Inspect AcademicCourse class,register an
academic course and re-inspect
theAcademicCourseCourse
2 Inspect NonAcademicCourse class,register a
non-academic course and re-inspect the
NonAcademicCourse class
3 Inspect NonAcademicCourse class again,
change the status of isTerminated to true and
re-inspect the NonAcademicCourse class
4 Display the detail of AcademicCourse and
NonAcademicCourse classes
Table 1Testing table

5.1 Test 1:

Objective Inspect AcademicCourse class,register an


academic course and re-inspect
theAcademicCourseCourse
Action • Create an object passing values to
asked parameters
• Inspect the AcademicCourse class

14
• Create an object the register with
parameter values as asked
• Re-inspect the AcademicCourse Class
Expected Result All the passed values were expected to be
seen while inspecting and re-inspecting
Actual Result All the values passed in the parameter were
shown while inspecting and re-inspecting
Conclusion The test was successful.
Table 2 Test 1

➢ Creating the Object of AcademicCourse Class

Figure 2 Creating the object of AcademicCourse Class

15
➢ Input the information of Course duration, course name level, Credit and Number of
assessments

Figure 3 Input the information of Course duration, course name level, Credit and Number of assessments

➢ Inspecting AcademicCourse Class

Figure 4 Inspecting AcademicCourse Class

16
➢ Calling the register method.

Figure 5 Calling the register method.

➢ Input the information of CourseLeader, lecturerName, Starting Date and completion


Date

Figure 6 Input the information of CourseLeader, lecturerName, Starting Date and completion Date

17
➢ Re-inspecting Academic Course

Figure 7 Re-inspecting Academic Course

5.2 Test 2

Objective Inspect NonAcademicCourse class register a


non-academic course and re-inspect the
NonAcademicCourse class
Action • Create an object passing values to
asked parameters.
• Inspect the NonAcademicCourse
• Create an object register with
parameter values as asked
• Re-inspect the NonAcademicCourse
Class
Expected Result All the passed values were expected to be
seen while inspecting and re-inspecting
Actual Result All the values passed in the parameter were
shown while inspecting and re-inspecting
The test was successful
Table 3 Test 2

18
➢ Creating Object for the class NonAcademicCourse

Figure 8 Creating Object for the class NonAcademicCourse

➢ Input all the information of Course duration, courseID, coursename and prerequisite

Figure 9 Input all the information of Course duration, courseID, coursename and prerequisite

19
➢ Inspect NonAcademicCourse Class

Figure 10 Inspect NonAcademicCourse Class

➢ Calling register method of NonAcademic Course.

Figure 11 Calling register method of NonAcademic Course.

20
➢ Input the information of CourseLeader, instructorName, startDate, completionDate,
examDate.

Figure 12 Input the information of CourseLeader, instructorName, startDate, completionDate, examDate.

21
➢ Re-inspecting NonAcademicCourse class

Figure 13 Re-inspecting NonAcademicCourse class

5.3 Test 3

Objectives Inspect NonAcademicCourse class again,


remove the non-academic course and re-
inspect the NonAcademicCourse class
Action • Inspect NonAcademicCourse
• Call the remove method
• Re-inspect NonAcademicCourse
Expected Result The value of isRemoved was expected to
change to true.
Actual Result The status of isRemoved was change to true.
Conclusion The test was successful
Table 4 Test 3

22
➢ Creating the object of NonAcademicCourse Class

Figure 14 Creating the object of NonAcademicCourse Class

➢ Input the information of course duration, courseID, coursename and prerequisite.

Figure 15 Input the information of course duration, courseID, coursename and prerequisite.

23
➢ Inspect NonAcademicCourse Class

Figure 16 Inspect NonAcademicCourse Class

➢ Calling void remove method

Figure 17 Calling void remove method

24
➢ Re-inspect NonAcademicCourse Class

Figure 18 Re-inspect NonAcademicCourse Class

5.4 Test 4

Objectives Display the detail of AcademicCourse and


NonAcademicCourse classes
• Create object of AcademicCourse and
NonAcademicCourse class
• Input all the information
Expected Result All the output were expected be seen as input
Actual Result All the output were seen as input
Conclusion The test was successful
Table 5 Test 4

25
Academic Course
➢ Input all the information of duration, courseID, courseName, level, Credit and
NumberofAssessments.

Figure 19 Input all the information of duration, courseID, courseName, level, Credit and NumberofAssessments.

➢ Calling display method of AcademicCourse Class

Figure 20 Calling display method of AcademicCourse Class

26
➢ Displaying the information after object creation of AcademicCourse Class

Figure 21 Displaying the information after object creation of AcademicCourse Class

➢ Input the information of CourseLeader, lecturers,startingDate and completionDate of


AcademicCourse Class

Figure 22 Input the information of CourseLeader, lecturers,startingDate and completionDate of AcademicCourse Class

27
➢ Displaying the information after calling register method of AcademicCourse Class

Figure 23 Displaying the information after calling register method of AcademicCourse Class

Non Academic Course


➢ Input the information of course duration, courseID, coursename and prerequisite.

Figure 24 Displaying the information after course starting

➢ Displaying the information after object creation of NonAcademicCourse Class

Figure 25 Displaying the information after object creation of NonAcademicCourse Class

28
➢ Input the information of CourseLeader, instructorName, startDate, completionDate,
examDate of NonAcademicCourse Class

Figure 26 Input the information of CourseLeader, instructorName, startDate, completionDate, examDate of


NonAcademicCourse Class

➢ Calling void display method of NonAcademicCourse Class

Figure 27 Calling void display method of NonAcademicCourse Class

29
➢ Displaying the information after calling register method of NonAcademicCourse Class

Figure 28 Displaying the information after calling register method of NonAcademicCourse Class

➢ Calling remove method of NonAcademicCourse Class

Figure 29 Calling remove method of NonAcademicCourse Class

30
➢ Calling display method after calling remove method of NonAcademicCourse Class

Figure 30 Calling display method after calling remove method of NonAcademicCourse Class

➢ Displaying the information after calling remove method of NonAcademicCourse Class

Figure 31 Displaying the information after calling remove method of NonAcademicCourse Class

31
6. Error and Correction:
During doing programming for the coursework, I have face many errors and programming
is not compile and run. Some of the error that I have faced during doing programming are
mentioned below:

6.1 Error 1: Error while calling super class display method:

Figure 32 Error while calling super class display method:

In the above figure, an error is occur while calling super class display method in the child class
NonAcademicCourse. The error was that to call super class, I forget to add full stop(.) after
super. As we can see the complier show undeclared method. To correct that error add full
stop(.) in between the super and display.

6.2 Correction of calling the super class display method:

Figure 33 Correction of calling the super class display method:

6.3 Data Type in Error:

Figure 34 Data Type in Error:

32
In the figure above, there is the data type error in the parameterized constructor. I have
forget to write data type in the parameter constructor which show syntax error by the
complier. To correct that error, write the data type in the parameter constructor.

6.4 Correction of Data Type Error:

Figure 35 Correction of Data Type Error

6.5 Logical Error:

33
Figure 36 Logical Error:

Logical error is the your program compiles and runs, but does the wrong thing. While
doing programming, the complier doesnot show syntax error but when I wiite the value
of ExamDate then the complier shows empty string as show in figure above.

34
6.6 Correction of Logical Error

35
Figure 37 Correction of Logical Error

I forget to initialized the ExamDate by being assigned the constructor value


i.e. this.ExamDate=examDate; After initializing ExamDate then only the complier show the
value of ExamDate as shown in figure above.

6.7 Symmetric Error

Figure 38 Symmetric Error

36
Figure 39 Correction of Symmetric Error.

You can see a semantic error when the syntax of your code is correct but the code usage isn't
correct. The most common semantic error is one in which the code uses a variable that isn't
initialized properly. In the Figure above I forget to write the String value inside the double
coded i.e. (‘’ “). Due to this, the complier show error and doesnot except the values.

6.8 Correction of Symmetric Error.


By writing the value inside the double coded i.e. (“ “ ) , the complier doesnot show any error
and take the given value as shown in figure above.

37
7. Conclusion
It was the first coursework of Java Programming given by the Sushil Poudel Sir. There was
an almost 3 weeks given to complete the coursework. I have done so many researches to
complete the coursework. When the module course started, I am new in Java programming
and it is difficult to understand the programming. But now it is better to understand java
programming.
This coursework helps me a lot to understand about java programming. During research, I
have got so many knowledge and information related to java programming. The main of the
program is to develop three classes named Courses as parent class and Academic course
and nonacademic course as child class and hence develop the program with the help of
inheritance. I have also gotten the knowledge related to Getter and Setter method where
Getter method return the value and Setter method set the new value.
This coursework is not easy task for me. I have done hard work and effort to complete this
coursework. While doing this coursework I have learnt to manage the time according to
situation. The lecture slides provided to us by the teachers helped us tons for the
completion of the report. The challenging coursework was completed with many testings
and error solving. All those errors encountered during the coursework were solved by the
study of varied studying materials which helped to enhance my learning and skills in
programming. So overall the coursework was interesting and has helped within the
development of program.

8. Bibliography
Guru99. (2021, March 30). What is Java? Definition, Meaning & Features of Java Platforms. Retrieved
from www.guru99.com: https://www.guru99.com/java-platform.html

38
9. Appendix
The code of our program coursework is given below:

9.1 Appendix 1: Course


/**
* Write a description of class Course here.
* This class contains 3 attribute of String and 1 attribute of integer.
* @author (Anjal Mahato)
*@London Met ID(20048637)
*@version(a version number or a date)
*/

public class Course{


public String courseID;//A String that
public String courseName;
public int duration;
public String courseLeader;

public Course(int duration,String courseID, String courseName)


/**
* This is the parameterized constructor.
* This constructor accepts 3 attributes i.e. duration, courseID, coursename
*/
{
this.courseID=courseID;
this.courseName=courseName;

39
this.duration=duration;
courseLeader="";
}
/**
* Below there is a Getter method for each attributes.
*/
public String getCourseID()//Getter method for courseID
{
return courseID;
}
public String getCourseName()//Getter method for courseName
{
return courseName;
}
public int getDuration()//Getter method for duration
{
return duration;
}
public String getCourseLeader()//Getter method for courseLeader
{
return courseLeader;
}

public void setCourseLeader(String CourseLeader)//Setter method for courseLeader


{
this.courseLeader=CourseLeader;
}

40
/**
* Setter method set the new value to the parameter.
* Setter method for the courseLeader attribute set new value to the parameter.
*/
public void display()
/**
* Display method display the details of courseID, courseName, duration attributes
*/
{
System.out.println("The ID of the course is"+getCourseID());
System.out.println("The name of the course is"+getCourseName());
System.out.println("The time to complete this course is"+getDuration());
if(!courseLeader.isEmpty())

{
System.out.println("The name of the course leader is"+getCourseLeader());//Printing
course leader name of name is not null
}
}
}

9.2 Appendix 2: AcademicCourse


/**
* Write a description of AcademicCourse Class here.
* This is the subclass of Course.
* This class contains 7 attributes.
* There are 5 attributes which stores String value.
* There is 1 attribute which stores 1 double value.

41
* There is one attribute which store 1 boolean value.
* @author (Anjal Mahato)
* @london met ID (20048637)
* @version(a version number or a date)
*/

public class AcademicCourse extends Course{


private String LecturerName;
private String Level;
private String Credit;
private String StartingDate;
private String CompletionDate;
private double NumberOfAssessments;
private boolean isRegistered;
/**These are the attributes of AcademicCourse Class
* They cannot be access by other because they are private values
*/
public AcademicCourse( int duration, String courseID, String courseName,String
Level,String Credit,double NumberOfAssessments)
/**This the parameterized constructor
* This constructor accepts 6 parameters values of integers, String and double data types
*/{
super(duration,courseID, courseName);//Calling super class for parent class i.e Course
class
this.Level=Level;
this.Credit=Credit;

42
this.NumberOfAssessments=NumberOfAssessments;
this.LecturerName="";
this.StartingDate="";
this.CompletionDate="";
this.isRegistered=false;
}
/**
* Below are the Getter Method of AcademicCourse that return value.
*/
public String getlecturers(){ //Getter method for LecturerName
return LecturerName;
}
public String getlevel(){ //Gettter method for Level
return Level;
}
public String getcredit(){ // Getter method for Credit
return Credit;
}
public String getstartingDate(){// Getter method for StartingDate
return StartingDate;
}
public String getcompletionDate(){//Getter method for CompletionDate
return CompletionDate;
}
public double getnumberOfAssessments(){//Getter method for NumberOfAssessments
return NumberOfAssessments;
}

43
public boolean getIsRegistered(){//Getter method for isRegistered
return isRegistered;
}
public void setlecturers(String lecturers){//Setter method for LecturerName
LecturerName=lecturers;
}
/**
* Setter method for the LecturerName as lecturers where setter method set new value to
parameter
*/
public void setnumberOfAssessments(double numberOfAssessments){//Setter method for
NumberOfAssessments
NumberOfAssessments=numberOfAssessments;
}
/**
* Setter method for NumberOfAssessments as numberOfAssessments that set new value
to the parameter
*/
public void registerAcademicCourse(String CourseLeader, String lecturers, String
startingDate, String completionDate)
/**
* This is the void method that donot return the value
* It works in if condition
*/
{
if(isRegistered==true){
System.out.println("The course has been registered and the lecturer name is"
+getlecturers());
System.out.println("The starting date of course is"+getstartingDate());

44
System.out.println("The date when course is completed is "+getcompletionDate());
}
else{
super.setCourseLeader(CourseLeader);//Calling CourseLeader from the parent class
LecturerName=lecturers;
StartingDate=startingDate;
CompletionDate=completionDate;
isRegistered=true;
}
}
public void displayDetailsOfCourse()
/**
* This the void method.
* This method display the details of Lecturer, level, credit, starting date, completion date
and number of assessments of academic course
*/
{
super.display();//Display courseName, courseID, duration of the parent class i.e. Course
class

if(isRegistered==true){
System.out.println("The name of the lecturer is"+getlecturers());
System.out.println("The level of academic course is"+getlevel());
System.out.println("The credit of the academic course is"+getcredit());
System.out.println("The starting date of academic course is"+getstartingDate());
System.out.println("The completion date of the academic course
is"+getcompletionDate());
System.out.println("The number of assesssments is"+getnumberOfAssessments());

45
}
}
}

9.3 Appendix 3: NonAcademicCourse


/**
* Write a description of class NonAcademicCourse.
* This is the subclass of Course class.
* This class contains 5 attributes of String and two boolean type.
* @author (Anjal Mahato)
* @london met id(20048637)
* @version (a version number or a date)
*/

public class NonAcademicCourse extends Course{


private String InstructorName;
private String StartDate;
private String completionDate;
private String ExamDate;
private String prerequisite;
private boolean isRegistered;
private boolean isRemoved;// Declaring attributes as private
public NonAcademicCourse(int duration,String courseID,String coursename,String
prerequisite)
{
/**
* Declaring NonAcademicCourse as constructor
*/

46
super(duration,courseID,coursename);//Calling duration, courseID and coursename from
parent class Course
this.prerequisite=prerequisite;
this.InstructorName="";
this.StartDate="";
this.completionDate="";
this.ExamDate="";
this.isRegistered=false;
this.isRemoved=false;
}
/**
* Making of return type of Getter Method
* 7 getter or accessor method.
* 5 method return String data
* 2 method return boolean data
*/
public String getinstructorName()//Getter method for InstructorName
{
return InstructorName;
}

public String getstartDate()// Getter method of StartDate


{
return StartDate;
}
public String getCompletionsDate()//Getter method for completionDate
{

47
return completionDate;
}
public String getexamDate()//Getter method for examDate
{
return ExamDate;
}
public String getPrerequisite()//Getter method for prerequisite
{
return prerequisite;
}
public boolean getIsRegistered()//Getter method for isRegistered
{
return isRegistered;
}
public boolean getIsRemoved()//Getter method for isRemoved
{
return isRemoved;
}
public void setinstructorName(String instructorName)
/**
* This is the non return or void type method
* it works with if else condition
*/

{
if(isRegistered==false)

48
{
this.InstructorName=instructorName;
}
else{
System.out.println("The course is already register");
}
}

public void registerNonAcademicCourse(String CourseLeader, String instructorName, String


startDate, String CompletionsDate, String examDate)
/**
* void method doesnot return the value.
* works in boolean data type wheather isRegistered is true or false
*/
{
if(isRegistered==false)//Display the details if isRegistered is false
{
setinstructorName(instructorName);
setCourseLeader(CourseLeader);
isRegistered=true;
}
else{
System.out.println("The course is already started from"+getstartDate());
}

this.StartDate=startDate;

49
this.completionDate=CompletionsDate;
this.ExamDate=examDate;

}
public void removeCourse()
/**
* it is a void method that doesnot return the value
* it works in if else condition wheather condition is true or false
*/

{
if(isRemoved==true)//Display the message if isRemoved is false
{
System.out.println("The course has been removed!");
}
else{
setCourseLeader(courseLeader);
this.InstructorName="";
this.StartDate="";
this.completionDate="";
this.ExamDate="";
this.isRegistered=false;
this.isRemoved=true;
}
}
public void displayDetailsOfNonAcademicCourse()
/**

50
* This the void method that doesnot return the value
* Display the details of non academic course if the value is true
*/

{
super.display();//calling the display method from parent class
if(isRegistered==true)//Display if isRegistered is true
{

System.out.println("The name of the Instructor Name " +getinstructorName());


System.out.println("The starting date of non-academic course is " +getstartDate());
System.out.println("The completion date of non-academic course is "
+getCompletionsDate());
System.out.println("The exam date of non-academic course is " +getexamDate());
}
}
}

51

You might also like