Object Oriented Programming CS F213: BITS Pilani
Object Oriented Programming CS F213: BITS Pilani
CS F213
J. Jennifer Ranjani
email: [email protected]
Chamber: 6121 B, NAB
BITS Pilani Consultation: Appointment by e-mail
Pilani Campus
OOP Basics
BITS Pilani
Pilani Campus
Basic OOP concepts
• Class
• Object
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Vehicle Objects
Polygon Objects
Polygon Class
Abstract Attributes: Vertices, Border,
Into Color, FillColor
Operations: Draw(), Erase(), Move()
Student Circle
Account
class Student{
int id; Creates a data
String name;
type Student
}
// Class Student
Student s1;
• Encapsulation is:
– Binding the data with the code that manipulates it.
– It keeps the data and the code safe from external interference
Parent
Inherited
capability
Child
Shape
Circle Rectangle
move(newCentre){ move(newCentre){
centre = newCentre; centre = newCentre;
} }
centre move(newCentre){
centre = newCentre
}
move(newCentre)
Circle Rectangle
height
radius width
area() area()
circumference() circumference()