Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

C2 

Class Test
3 classes – 1 superclass, 2 subclasses with private attributes and
public get/set methods for the attributes. Arrow from subclass to
Employee

superclass to show
Private:
Name
Designation
Department

Public:
getName()
Inheritance - Arrow from subclass to superclass to show
setName()
getDepartment()
inheritance
setDepartment()
getDesignation()
setDesignation()
show() Polymorphism – show method for all 3 classes

1.Proper rectangle shape with 3 segments : class name, private, public
DailyRatedEmployee FullTimeEmployee 2. No __init__ or any other _functionname. No python related syntax
Private:
RatePerDay
Private:
Salary
3. Don’t need constructor (__init__ in python)
DaysWorked

Public:
OTAllowancePerHour
3. Attributes with getter/setter. Functions will have ()
getRatePerDay()
setRatePerDay()
Public:
getSalary() 4. Construct classes from bottom to top. Bring up common attributes.
getDaysWorked() setSalary()
setDaysWorked() getOTAllowance() 5. Arrow points from subclass to superclass.
computePay() setOTAllowance()
show() computePay()
show()
6.Polymorphism – inheritance and overrides methods
(b) The sub-classes (DailyRatedEmployee and FullTimeEmployee) inherit all the attributes and methods of the
Employee class. The methods getName, SetName, getDepartment, setDepartment, getDesignation,
setDesignation are inherited without changes to the implementation and the no coding are required,
hence code reused is achieved.

(c) Polymorphism refers to an object’s ability to take different forms. It allows subclasses to have methods with the
same name as methods in their superclasses. It gives the ability for a program to call the correct method depending
on the type of object that is used to call it.

The method show in both the subclasses overrides the superclass show. If the subclass object
(DailyRatedEmployee) is used to call show, then the subclass’s version of the method is invoked. If the superclass
object (Employee) is used to call show, then the superclass method will be invoked.

Encapsulation refers to the combining of data and functions into a single object.
The Employee class’s attributes (Name, Designation, Departmentt) and methods (getName(), setName(),
getDesignation(), setDesignation(), getDepartment(), setDepartment()) that operate on the attributes are bundled
together in a class.
1. Before and after
2. Linked List – head pointer
3. Explains what you draw so examiner can 
understand.
1. Explain what the pointers are for
2. Comments in your code so examiner 
understand (not too much)
3. Missing last 2 lines of code
Generally for sorting orders :
a. Ascending  (Low to High)    1,2,3 ….8,9,10
b. Descending  (High to Low)  10,9,8 …3,2,1
1. Missing node structure!
2. Missing assumptions!
3. There is no need to define a function
4. No need to use recursive function
5. The question stated pseudocode …
6.Note that probe is a POINTER ..
so probe < target is WRONG!

You might also like