Professional Documents
Culture Documents
Lab G ui des
Contents
Unit 3: Classes and Objects............................................................................................................. 2
Lab Guide 2: Inheritance, Encapsulation......................................................................................2
Objectives:.................................................................................................................................... 2
Problem Descriptions:................................................................................................................... 2
Functional Requirements:............................................................................................................. 3
Guidelines:.................................................................................................................................... 3
Lab Guides Mr Tuan Cat
CODE: JPL.S.L006
TYPE: SHORT
DURATION: 60 MINUTES
Problem Descriptions:
This exercise will be developed from JPL.S.L006 and adding an Actionable interface, an EnglishTeacher
class.
The Teacher abstract class:
Instance variables:
o designation: for teacher designation
Constructor:
o public Teacher(): A default constructor, it should initialize the attribute to null or 0 )
o public Teacher (String designation, String collegeName): A constructor with parameters, it
creates the teacher object by setting the two fields to the passed values
Instance methods:
o Getter/Setter methods: are used to get/set the value
o public void teach(String content){}
The MathTeacher class that extends Teacher:
Instance variables:
o mainSubject: the main subject
Constructor:
o public MathTeacher(): A default constructor, it should initialize the attribute to null or 0 )
o public MathTeacher (String designation, String collegeName, String mainSubject): A
constructor with parameters, it creates the teacher object by setting the three fields to the
passed values.
Instance methods:
o Getter/Setter methods: are used to get/set the value
o public void teach(String content){}: override the parent’s method
o public String toString(): This method allows the math teacher to be easily printed out to the
screen
Create EnglishTeacher, this class also extend above Teacher and implement Actionable. Add a new
method teach(int duration) in Teacher class
TeacherManagement class:
Project struture:
Actionable interface
Teacher class
MathTeacher class
EnglishTeacher class
TeacherManagement class
How to run:
Click Run menu | choose Run as:
Results:
-- THE END --