You are on page 1of 4

Callyn Naidoo

Introduction
To OOP 500

Assignment
Question One:

1.1

-Polymorphism: In object-oriented programing polymorphism refers to a programming


languages ability to process objects differently depending on their data type or class. It is the
ability to redefine methods for derived classes example, given a base class shape,
polymorphism enable the programmer to define different area methods for any number of
derived classes. No matter what shape am object is, applying the area method to it will
return the correct result. Polymorphism is considered to be requirement of true object-
oriented programming language (OOPL)

- Inheritance: Inheritance is a mechanism in which one class acquires the property of


another class. With Inheritance, we can reuse the fields and methods of the existing class.
Hence, inheritance facilitates reusability and is an important concept of OOPs. Inheritance
will occur when an object inherits data or traits from its parent. Each superclass will be
composed of subclasses, and plays an important role in the object oriented.

- Encapsulation: Encapsulation can be used to hide data members and member’s functions.
Encapsulation is one of the fundamental (OOP).Under this definition, encapsulation means
that the internal representation of an object is generally hidden from view outside of the
objects definition. Typically, only the objects own methods can directly inspect or
manipulate its fields.

1.2

Steps:

Step 1: start

Step 2: initialize the know variables: max hours worked with no overtime(MaxNoOvertime),
bonus rate for overtime hours (BounsRate), non taxable payroll amount (MaxNoDue), tax
rate (Due).

Step 3: Enter : hours worked overtime (HoursWorked) and Hourly rate (HourRate).

Step 4: If (HourWorked-MaxNoOvertime)<=0 then

GrossPay=HoursWorked*HourRate;

Else
GrossPay = HourRate*(MaxNoOvertime + BounsRate*(HoursWorked –
MaxNoOvertime));

Step 5: If GrossPay <= MaxNoDue then

NetPay=GrossPay;

Else

NetPay=GrossPay-Due*(GrossPay-MaxNoDue);

Step 6: Display: GrossPay, NetPay;

Step 7: End.

// Step 1: START

Step 2: Enter number of hours worked

Step 3: Input hours

Step 4: Enter hourly payrate

Step 5: input payrate

Step 6: Multiply hours by payrate store results in netpay

Step 7: netpay

Step 8: END// if the first one is wrong

1.3

Public class payroll form


Private Sub HoursWorked_TextChanged( )
Handles Hoursworked. TextChanged
If Hours

Question Two:
2.1

Class House

Private class address

Private number price

Private number baths

Public setaddress(char mewadress)

Address=newaddress

Return

Public setprice(number = newprice)

If newprice>0 then

Price=newprice

Endif

2.2

Public class house {

Private int size;

Private string toppings;

Private double price;

Public House(){

Setsize(12)

Settoppings(

You might also like