Uploaded by sanacharya000

20043468

advertisement
Module Code & Module Title
CS4001NI Programming
COURSEWORK-1
Assessment Weightage & Type
30% Individual Coursework
Semester and Year
Spring 2021
Student Name: Sampanna Acharya
Group: M3
London Met ID: 20049468
College ID: NP01MM4S210067
Assignment Due Date: 23rd may
Assignment Submission Date: 23rd may
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.
Contents
1. Introduction ....................................................................................................................................... 1
2. Class Diagram .................................................................................................................................. 2
2.1. Course (Parent Class)............................................................................................................... 2
2.2. AcademicCourse (Child Class) ................................................................................................ 3
2.3. NonAcademicCourse (Child Class) ......................................................................................... 4
3. Pseudocode ...................................................................................................................................... 6
3.1. Course ........................................................................................................................................ 6
3.2. AcademicCourse ....................................................................................................................... 8
3.3. NonAcademicCourse .............................................................................................................. 11
4. Method Description ........................................................................................................................ 17
4.1. Course (Parent Class)............................................................................................................. 17
getCourseID() .............................................................................................................................. 17
getCourseName()........................................................................................................................ 17
getCourseLeader() ...................................................................................................................... 17
getDuration()................................................................................................................................ 17
setCourseLeader() ...................................................................................................................... 17
display() ....................................................................................................................................... 17
4.2. AcademicCourse (Child Class) .............................................................................................. 17
getLecturrerName()..................................................................................................................... 17
getLevel() ..................................................................................................................................... 17
getCredit() .................................................................................................................................... 17
getStartDate() .............................................................................................................................. 18
getCompletionDate()................................................................................................................... 18
getNoOfAssessments() .............................................................................................................. 18
getisRegistered() ......................................................................................................................... 18
setLecturerName() ...................................................................................................................... 18
setNoOfAssessments()............................................................................................................... 18
register()....................................................................................................................................... 18
display() ....................................................................................................................................... 18
4.3. NonAcademicCourse (Child Class) ....................................................................................... 19
getInstructorName() .................................................................................................................... 19
getDuration()................................................................................................................................ 19
getStartDate() .............................................................................................................................. 19
getCompletionDate()................................................................................................................... 19
getExamDate() ............................................................................................................................ 19
get PreRequisite() ....................................................................................................................... 19
get isRegistered() ........................................................................................................................ 19
getisRemoved() ........................................................................................................................... 19
setInstructorName() .................................................................................................................... 19
register()....................................................................................................................................... 19
remove()....................................................................................................................................... 20
display() ....................................................................................................................................... 20
5. Testing ............................................................................................................................................. 21
5.1. Test 1........................................................................................................................................ 21
5.2. Test 2........................................................................................................................................ 24
5.3. Test 3........................................................................................................................................ 27
5.4. Test 4........................................................................................................................................ 29
6. Error Detection and Correction...................................................................................................... 31
6.1. Error 1....................................................................................................................................... 31
6.2. Error 2....................................................................................................................................... 32
6.3. Error 3....................................................................................................................................... 33
7. Conclusion ...................................................................................................................................... 34
8. Bibliography .................................................................................................................................... 35
9. Appendix ......................................................................................................................................... 36
9.1. Course (Parent Class)............................................................................................................. 36
9.2. AcademicCourse (Child Class) .............................................................................................. 38
9.3. NonAcademicCourse (Child Class) ....................................................................................... 43
Table of Figure
Figure 1: Class Diagram ...................................................................................................................... 5
Figure 2: Creating Object ................................................................................................................... 22
Figure 3: Inspecting Object ................................................................................................................ 22
Figure 4: Registering an academic course ....................................................................................... 23
Figure 5: Re-inspection Object .......................................................................................................... 23
Figure 6: Creating Object ................................................................................................................... 25
Figure 7: Inspecting Object ................................................................................................................ 25
Figure 8: Registering NonAcademicCourse ..................................................................................... 26
Figure 9: Re-inspecting Object .......................................................................................................... 26
Figure 10: Inspecting Object .............................................................................................................. 27
Figure 11: Calling remove method .................................................................................................... 28
Figure 12: Re-Inspecting Object........................................................................................................ 28
Figure 13: Calling display method ..................................................................................................... 29
Figure 14: AcademicCourse details being displayed....................................................................... 30
Figure 15: NonAcademicCourse details being displayed ............................................................... 30
Figure 16: Error 1................................................................................................................................ 31
Figure 17: Error 1 Fixed ..................................................................................................................... 31
Figure 18: Error 2................................................................................................................................ 32
Figure 19: Error 2 Fixed ..................................................................................................................... 32
Figure 20: Error 3................................................................................................................................ 33
Figure 21: Error 3 Fixed ..................................................................................................................... 33
Table of Tables
Table 1: Course Class .......................................................................................................................... 2
Table 2: Academic Course................................................................................................................... 3
Table 3: NonAcademicCourse ............................................................................................................. 4
Table 4: Test 1 .................................................................................................................................... 21
Table 5: Test 2 .................................................................................................................................... 24
Table 6: Test 3 .................................................................................................................................... 27
Table 7: Test 4 .................................................................................................................................... 29
CS4001NI
Programming
1. Introduction
This is the first coursework of Programming. It was given to us on the 8 th week.
The coursework required us to implement a real world problem scenario using Objectoriented concept of Java. The requirements were to create a class to represent a
Course, together with its two subclasses to represent an Academic course and a Nonacademic Course respectively. Additionally this report contains detailed explanation
about the methods, class diagrams and testing.
“Java is a programming language and computing platform first released by Sun
Microsystems in 1995. There are lots of applications and websites that will not work
unless you have Java installed, and more are created every day. Java is fast, secure,
and reliable. From laptops to datacenters, game consoles to scientific supercomputers,
cell phones to the Internet, Java is everywhere!” (java.com, 2021)
Sampanna Acharya
1
CS4001NI
Programming
2. Class Diagram
2.1. Course (Parent Class)
Course
Instance Variable
+courseID : String
+coursename : String
+courseLeader : String
+duration : int
Methods
+Course (CourseID : String, coursename : String, duration : int)
+getCourseID() : String
+getCoursename() : String
+getCourseLeader() : String
+getDuration() : int
+setCourseLeader(courseLeader : String) : void
+display() : void
Table 1: Course Class
Sampanna Acharya
2
CS4001NI
Programming
2.2. AcademicCourse (Child Class)
AcademicCourse
Instance Variable
+LecturerName : String
+Level : String
+Credit : String
+StartDate : String
+CompletionDate : String
+NoOfAssessments : int
+isRegistered : boolen
Methods
+AcademicCourse (courseID : String, coursename : String, duration : int, Level : String,
Credit : String, NoOfAssessments : int)
+getLecturerName() : String
+getLevel() : String
+getCredit() : String
+getStartDate() : String
+getCompletionDate() : String
+getNoOfAssessments() : int
+getisRegistered(): boolean
+setLecturerName(LecturerName : String) : void
+setNoOfAssessments(NoOfAssessments : int) : void
+register(courseLeader : String, LecturerName : String, StartDate : String,
CompletionDate: String) : void
+display() : void
Table 2: Academic Course
Sampanna Acharya
3
CS4001NI
Programming
2.3. NonAcademicCourse (Child Class)
NonAcademicCourse
Instance Variable
+InstructorName : String
+Duration : int
+StartDate : String
+CompletionDate : String
+ExamDate : String
+PreRequisite : String
+isRegistered : boolean
+isRemoved : boolean
Methods
+NonAcademicCourse(courseID : String, courename : String, duration : int,
PreRequisite : String)
+getInstructorName() : String
+getDuration() : int
+getStartDate() : String
+getCompletionDate() : String
+getExamDate() : String
+getPreRequisite() : String
+getisRegistered() : boolean
+getisRemoved() : boolean
+register(courseLeader : String, InstructorName : String, StratDate : String,
CompletionDate : String, ExamDate : String) : void
+remove() : void
+display() : void
Table 3: NonAcademicCourse
Sampanna Acharya
4
CS4001NI
Programming
Figure 1: Class Diagram
Sampanna Acharya
5
CS4001NI
Programming
3. Pseudocode
3.1. Course
CALL Course (String courseID, String coursename, int duration)
DO
this.courseID=courseID;
this.coursename=coursename;
this.duration=duration;
this.courseLeader="";
END DO
CALL getCourseID()
DO
return courseID
END DO
CALL getCourseLeader()
DO
return courseLeader
END DO
CALL getDuration()
DO
return duration
END DO
Sampanna Acharya
6
CS4001NI
Programming
CALL setCourseLeader(String courseLeader)
DO
this.courseLeader=courseLeader;
END DO
CALL display()
DO
IF(courseLeader.length()==0)
DO
DISPLAY(“Course ID=” + courseID)
DISPLAY(“Course Name=” + coursename)
DISPLAY(“Duration=” + duration)
END DO
ELSE
DO
DISPLAY(“Course ID=” + courseID)
DISPLAY(“Course Name=” + coursename)
DISPLAY(“Duration=” + duration)
DISPLAY(“Course Leader=” + courseLeader);
END DO
END DO
Sampanna Acharya
7
CS4001NI
Programming
3.2. AcademicCourse
CALL AcademicCourse(String courseID, String coursename, int duration, String Level,
String Credit, int NoOfAssessments)
DO
super(courseID, coursename, duration)
this.Level=Level
this.Credit=Credit
this.NoOfAssessments=NoOfAssessments
LecturerName=””
StartDate=””
CompletionDate=””
isRegistered=false
END DO
CALL getLecturerName()
DO
return LecturerName
END DO
CALL getLevel()
DO
return Level
END DO
Sampanna Acharya
8
CS4001NI
Programming
CALL getCredit()
DO
return Credit
END DO
CALL getStartDate()
DO
return StartDate
END
CALL getCompletionDate()
DO
return CompletionDate
END DO
CALL getNoOfAssessments()
DO
return NoOfAssessments
END DO
CALL isRegistered()
DO
return isRegistered
END DO
CALL setLecturerName(String LecturerName)
DO
Sampanna Acharya
9
CS4001NI
Programming
this.LecturerName=LecturerName;
END DO
CALL setNoOfAssessments(int NoOfAssessments)
DO
this.NoOfAssessments=NoOfAssessments
END DO
CALL resigter (String courseLeader, String LecturerName, String StartDate, String
CompletionDate)
DO
IF(isRegistered==true )
DO
super.getCourseLeader()
DISPLAY("The course is already registered")
DISPLAY ("Start Date="+ StartDate)
DISPLAY ("Completion Date=" + CompletionDate)
END DO
ELSE
DO
super.setCourseLeader(courseLeader)
this.LecturerName=LecturerName
this.StartDate=StartDate
this.CompletionDate=CompletionDate
isRegistered=true
Sampanna Acharya
10
CS4001NI
Programming
END DO
END DO
CALL display()
DO
super.display()
IF(isRegistered==true)
DO
DISPLAY("Lecturer Name=" + LecturerName)
DISPLAY ("Level=" + Level)
DISPLAY ("Credit=" + Credit)
DISPLAY ("Start Date=" + StartDate)
DISPLAY ("Completion Date=" + CompletionDate)
DISPLAY ("Number of Assessments=" + NoOfAssessments)
END DO
END DO
3.3. NonAcademicCourse
CALL NonAcademicCourse(String courseID, String coursename, int duration, String
PreRequisite)
DO
super(courseID, coursename, duration)
this.PreRequisite=PreRequisite
Sampanna Acharya
11
CS4001NI
Programming
StartDate=""
CompletionDate=""
ExamDate=""
isRegistered=false
isRemoved=false
END DO
CALL getInstructorName()
DO
return InstructorName
END DO
CALL getDuration()
DO
return Duration
END DO
CALL getStartDate()
DO
return StartDate
END DO
CALL getCompletionDate()
DO
return CompletionDate
Sampanna Acharya
12
CS4001NI
Programming
END DO
CALL getExamDate()
DO
return ExamDate
END DO
CALL getPreRequisite()
DO
return PreRequisite
END DO
CALL getisRegistered()
DO
return isRegistered
END DO
CALL getisRemoved()
DO
return isRemoved
END DO
CALL setInstructorName(String InstructorName)
DO
IF(isRegistered==false )
DO
Sampanna Acharya
13
CS4001NI
Programming
this.InstructorName=InstructorName
END DO
ELSE
DO
DISPLAY("The course is already registered so it is not possible to change
instructor name")
END DO
CALL register(String courseLeader, String InstructorName,String StartDate, String
CompletionDate, String ExamDate)
DO
this.StartDate=StartDate
this.CompletionDate=CompletionDate
this.ExamDate=ExamDate
IF(isRegistered==false)
DO
setInstructorName(InstructorName)
isRegistered=true
END DO
ELSE
DO
DISPLAY( "Cannot register, Course has already been registered")
END DO
Sampanna Acharya
14
CS4001NI
Programming
END DO
CALL remove()
DO
IF(isRemoved==true)
DO
DISPLAY("The course is already removed")
END DO
ELSE
DO
super.setCourseLeader("")
InstructorName=""
StartDate=""
CompletionDate=""
ExamDate=""
isRegistered=false
isRemoved=true
END DO
END DO
CALL display()
DO
super.display()
Sampanna Acharya
15
CS4001NI
Programming
IF(isRegistered==true)
Do
DISPLAY("Instructor Name=" + InstructorName);
DISPLAY("Start Date =" + StartDate)
DISPLAY("Completion Date=" + CompletionDate)
DISPLAY("Exam Date=" + ExamDate)
END DO
END DO
Sampanna Acharya
16
CS4001NI
Programming
4. Method Description
4.1. Course (Parent Class)
getCourseID()
This method is used to get the Course ID.
getCourseName()
This method is used to get the Course Name.
getCourseLeader()
This method is used to get the Course Leader.
getDuration()
This method is used to get the Duration of course.
setCourseLeader()
This method is used to set the name of Course Leader.
display()
This method is used to print details of class under certain conditions. If
courseLeader is empty it will print Course ID, Course Name and Duration. If it is
not empty Course Leader will also get printed.
4.2. AcademicCourse (Child Class)
getLecturrerName()
This method is used to get the Lecturer Name.
getLevel()
This method is used to get the Level.
getCredit()
This method is used to get the Credit.
Sampanna Acharya
17
CS4001NI
Programming
getStartDate()
This method is used to get the Start Date of Academic Course.
getCompletionDate()
This method is used to get the Completion Date of the Academic Course.
getNoOfAssessments()
This method is used to the No of Assessments of Academic Course.
getisRegistered()
This method is used to find out if the Academic Course is Registered or
not.
setLecturerName()
This method is used to set the name of Lecturer.
setNoOfAssessments()
This method is used to set the No of Assessments.
register()
This method is used to register a course under certain conditions. If the
course is already registered a message will be displayed (“The course is already
registered”). If it is not registered then the Course Leader, Lecturer Name, Start
Date and Completion Date will be set.
display()
This method displays the content of Academic course on certain
conditions. If the Academic Course is already registered then it will print Lecturer
Name, Level, Credit, Start Date, Completion Date and Number of Assessments.
Sampanna Acharya
18
CS4001NI
Programming
4.3. NonAcademicCourse (Child Class)
getInstructorName()
This method is used to get the Instructor Name.
getDuration()
This method is used to get the Duration.
getStartDate()
This method is used to get the Start Date of Academic Course.
getCompletionDate()
This method is used to get the Completion Date of the Academic Course.
getExamDate()
This method is used to get the Exam Date.
get PreRequisite()
This method is used get the Pre-Requisite of Non Academic Course.
get isRegistered()
This method is used check if Non Academic Course is Registered or not.
getisRemoved()
This method is used check if the Non Academic Couse is Removed or not.
setInstructorName()
This method is used set the instructor name under certain condition. If the
course is not registered then the Instructor Name will be set. If it is already
registered a certain message will be displayed.
register()
This method is used to register a Non Academic Course. This method will
set the Start Date, Completion Date and Exam Date. And if the course is already
registered then it will print out a message. If it has not been registered then it will
set the instructor name and set Registered to true.
Sampanna Acharya
19
CS4001NI
Programming
remove()
This method is used to remove the contents of Non Academic Course
under certain conditions. If the contents have already been removed it will display
a message. If it has not been removed then it will remove all the contents of Non
Academic Course.
display()
This method is used to display the contents of Non Academic Course
under conditions. First it will display the content of Course Class. Then it will
check if the course is registered or not. If it is registered then it will print Instructor
Name, Start Date, Completion Date, and Exam Date.
Sampanna Acharya
20
CS4001NI
Programming
5. Testing
5.1. Test 1
Objective
Inspect AcademicCourse class, register an
academic course, and re-inspect the
AcademicCourse Class
Action
Object is created in AcademicCourse
The object is inspected
courseLeader=”Ram”
LecturerName=”Shyam”
StartDate=”June”
CompletionDate=”July”
The object is re-inspected
Expected Result
Academic Course will be registered
Actual Result
Academic Course is registered
Conclusion
Test successful
Table 4: Test 1
Sampanna Acharya
21
CS4001NI
Programming
Figure 2: Creating Object
Figure 3: Inspecting Object
Sampanna Acharya
22
CS4001NI
Programming
Figure 4: Registering an academic course
Figure 5: Re-inspection Object
Sampanna Acharya
23
CS4001NI
Programming
5.2. Test 2
Objective
Inspect NonAcademicCourse class,
register a non-academic course and reinspect the NonAcademicCourse Class
Action
Object is created in NonAcademicCourse
Object is inspected
courseLeader=”Shyam”
InstructorName=”Hari”
StartDate=”August”
CompletionDate=”September”
ExamDate=”October”
The object is re-inspected
Expected Result
NonAcademicCourse will registered
Actual Result
NonAcademicCourse has registered
Conclustion
Test successful
Table 5: Test 2
Sampanna Acharya
24
CS4001NI
Programming
Figure 6: Creating Object
Figure 7: Inspecting Object
Sampanna Acharya
25
CS4001NI
Programming
Figure 8: Registering NonAcademicCourse
Figure 9: Re-inspecting Object
Sampanna Acharya
26
CS4001NI
Programming
5.3. Test 3
Objective
Inspect NonAcademicCourse class,
register a non-academic course
and re-inspect the NonAcademicCourse
Class
Action
Inspected NonAcademicCourse
Status of isTerminated Changed to “True”
The object is re-inspected
Expected Result
NonAcademicCourse Details of test2 will
be removed
Actual Result
NonAcademicCourse Details of test2 was
removed
Conclusion
Test successful
Table 6: Test 3
Figure 10: Inspecting Object
Sampanna Acharya
27
CS4001NI
Programming
Figure 11: Calling remove method
Figure 12: Re-Inspecting Object
Sampanna Acharya
28
CS4001NI
Programming
5.4. Test 4
Objective
Display the detail of AcademicCourse and
NonAcademicCourse classes
Action
Call display() method on both objects
Expected Result
Details of both classes will be displayed
Actual Result
Details of both classes was displayed
Conclusion
Test successful
Table 7: Test 4
Figure 13: Calling display method
Sampanna Acharya
29
CS4001NI
Programming
Figure 14: AcademicCourse details being displayed
Figure 15: NonAcademicCourse details being displayed
Sampanna Acharya
30
CS4001NI
Programming
6. Error Detection and Correction
6.1. Error 1
Figure 16: Error 1
Figure 17: Error 1 Fixed
Sampanna Acharya
31
CS4001NI
Programming
6.2. Error 2
Figure 18: Error 2
Figure 19: Error 2 Fixed
Sampanna Acharya
32
CS4001NI
Programming
6.3. Error 3
Figure 20: Error 3
Figure 21: Error 3 Fixed
Sampanna Acharya
33
CS4001NI
Programming
7. Conclusion
The coursework was completed within the allotted time with overcoming various
trials and errors. The coursework required lot of self-research on topic of java.
According to the requirements Class Diagrams, Pseudocodes and testing were done.
After a lot of hardwork and research the program was finally completed.
Through this coursework I learned about the basic of Object Oriented
Programming and its uses in real life scenarios. I learned a lot about how classes,
methods, object worked in Java. I also got a good handle on the basics of Java
Programming Language. Through this coursework I learned how testing is performed
and how to write Pseudocodes.
Some of the problems faced during this coursework were related to the concept
of Object Oriented Programming. As this was a new thing it took me some time to get a
good understanding on how classes, objects and methods worked. With the help of our
teacher and personal research I was able to understand it and complete the coursework
on time.
Sampanna Acharya
34
CS4001NI
Programming
8. Bibliography
java.com. (2021) What is Java and why do I need it? [Online]. Available from:
https://java.com/en/download/help/whatis_java.html [Accessed 23 May 2021].
Sampanna Acharya
35
CS4001NI
Programming
9. Appendix
9.1. Course (Parent Class)
import java.io.*;
public class Course {
private String courseID;
private String coursename;
private String courseLeader;
private int duration;
public Course(String courseID, String coursename, int duration)
{
this.courseID=courseID;
this.coursename=coursename;
this.duration=duration;
this.courseLeader="";
}
public String getCourseID()
{
return courseID;
Sampanna Acharya
36
CS4001NI
Programming
}
public String getCoursename()
{
return coursename;
}
public String getCourseLeader()
{
return courseLeader;
}
public int getDuration()
{
return duration;
}
public void setCourseLeader(String courseLeader)
{
this.courseLeader=courseLeader;
}
Sampanna Acharya
37
CS4001NI
Programming
public void display()
{
if(courseLeader.length()==0)
{
System.out.println("Course ID=" + courseID);
System.out.println("Course Name=" + coursename);
System.out.println("Duration=" + duration);
}
else
{
System.out.println("Course ID=" + courseID);
System.out.println("Course Name=" + coursename);
System.out.println("Duration=" + duration);
System.out.println("Course Leader=" + courseLeader);
}
}
}
9.2. AcademicCourse (Child Class)
import java.io.*;
public class AcademicCourse extends Course{
Sampanna Acharya
38
CS4001NI
Programming
private String LecturerName;
private String Level;
private String Credit;
private String StartDate;
private String CompletionDate;
private int NoOfAssessments;
private boolean isRegistered;
public AcademicCourse(String courseID, String coursename, int duration, String
Level, String Credit, int NoOfAssessments)
{
super(courseID, coursename, duration);
this.Level=Level;
this.Credit=Credit;
this.NoOfAssessments=NoOfAssessments;
LecturerName="";
StartDate="";
CompletionDate="";
isRegistered=false;
}
public String getLecturerName()
{
return LecturerName;
Sampanna Acharya
39
CS4001NI
Programming
}
public String getLevel()
{
return Level;
}
public String getCredit()
{
return Credit;
}
public String getStartDate()
{
return StartDate;
}
public String getCompletionDate()
{
return CompletionDate;
}
public int getNoOfAssessments()
{
return NoOfAssessments;
Sampanna Acharya
40
CS4001NI
Programming
}
public boolean getisRegistered()
{
return isRegistered;
}
public void setLecturerName(String LecturerName)
{
this.LecturerName=LecturerName;
}
public void setNoOfAssessments(int NoOfAssessments)
{
this.NoOfAssessments=NoOfAssessments;
}
public void register(String courseLeader, String LecturerName, String StartDate,
String CompletionDate)
{
if(isRegistered==true)
{
super.getCourseLeader();
System.out.println("The course is already registered");
System.out.println("Start Date="+ StartDate);
Sampanna Acharya
41
CS4001NI
Programming
System.out.println("Completion Date=" + CompletionDate);
}
else
{
super.setCourseLeader(courseLeader);
this.LecturerName=LecturerName;
this.StartDate=StartDate;
this.CompletionDate=CompletionDate;
isRegistered=true;
}
}
public void display()
{
super.display();
if(isRegistered==true)
{
System.out.println("Lecturer Name=" + LecturerName);
System.out.println("Level=" + Level);
System.out.println("Credit=" + Credit);
System.out.println("Start Date=" + StartDate);
System.out.println("Completion Date=" + CompletionDate);
System.out.println("Number of Assessments=" + NoOfAssessments);
}
}
Sampanna Acharya
42
CS4001NI
Programming
}
9.3. NonAcademicCourse (Child Class)
import java.io.*;
public class NonAcademicCourse extends Course {
private String InstructorName;
private int Duration;
private String StartDate;
private String CompletionDate;
private String ExamDate;
private String PreRequisite;
private boolean isRegistered;
private boolean isRemoved;
public NonAcademicCourse(String courseID, String coursename, int duration, String
PreRequisite)
{
super(courseID, coursename, duration);
this.PreRequisite=PreRequisite;
StartDate="";
CompletionDate="";
ExamDate="";
isRegistered=false;
isRemoved=false;
}
Sampanna Acharya
43
CS4001NI
Programming
public String getInstructorName()
{
return InstructorName;
}
public int getDuration()
{
return Duration;
}
public String getStartDate()
{
return StartDate;
}
public String getCompletionDate()
{
return CompletionDate;
}
public String getExamDate()
{
return ExamDate;
}
Sampanna Acharya
44
CS4001NI
Programming
public String getPreRequisite()
{
return PreRequisite;
}
public boolean getisRegistered()
{
return isRegistered;
}
public boolean getisRemoved()
{
return isRemoved;
}
public void setInstructorName(String InstructorName)
{
if(isRegistered==false)
{
this.InstructorName=InstructorName;
}
else
{
System.out.println("The course is already registered so it is not possible to
change instructor name");
Sampanna Acharya
45
CS4001NI
Programming
}
}
public void register(String courseLeader, String InstructorName,String StartDate,
String CompletionDate, String ExamDate)
{
this.StartDate=StartDate;
this.CompletionDate=CompletionDate;
this.ExamDate=ExamDate;
if(isRegistered==false)
{
setInstructorName(InstructorName);
isRegistered=true;
}
else
{
System.out.println("Cannot register, Course has already been registered");
}
}
public void remove()
{
if(isRemoved==true)
{
Sampanna Acharya
46
CS4001NI
Programming
System.out.println("The course is already removed");
}
else
{
super.setCourseLeader("");
InstructorName="";
StartDate="";
CompletionDate="";
ExamDate="";
isRegistered=false;
isRemoved=true;
}
}
public void display()
{
super.display();
if(isRegistered==true)
{
System.out.println("Instructor Name=" + InstructorName);
System.out.println("Start Date =" + StartDate);
System.out.println("Completion Date=" + CompletionDate);
System.out.println("Exam Date=" + ExamDate);
}
}
Sampanna Acharya
47
CS4001NI
Programming
}
Sampanna Acharya
48
Download