Professional Documents
Culture Documents
it’s Java…
An Introduction to Object-oriented
Programming using Java
Introduction to Classes
•Properties (all public)
•Methods (all public)
•Class Diagram
#include <iostream>
// provides std::cout
int main()
{
std::cout << "Hello, world!\n";
}
(define (fact n)
(if (= n 0)
1
(* n (fact (- n 1)))))
ENTRY POINT
Properties or State
# of liters of gas in tank
total # of km run so far
efficiency (km/liter)
Behavior
drive
load gas
change efficiency
check gas
check odometer reading
Behavior Method
Drive-------------------------------- drive ()
load gas ---------------------------- loadGas(NumOfLiter)
change efficiency-----------------changeEfficiency()
check gas---------------------------checkGas(NumOfLiter)
check odometer reading -------checkOdometer()
•Abstraction
•Encapsulation
•Inheritance
•Polymorphism
• Inheritance provides
the mechanism that
enables a program to
acquire and extend the
properties and
behavior of an existing
software.
• Polymorphism
provides the
mechanism that
enables child
classes to modify an
existing behavior of
the parent class.