Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Pertemuan 5 Review :: Kisi-kisi UTS ::. BASIC CONCEPTS OF OOP OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING.

Presentasi serupa


Presentasi berjudul: "Pertemuan 5 Review :: Kisi-kisi UTS ::. BASIC CONCEPTS OF OOP OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING."— Transcript presentasi:

1 Pertemuan 5 Review :: Kisi-kisi UTS ::

2 BASIC CONCEPTS OF OOP OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING MESSAGE PASSING

3 CLASSES Is the user defined data types A collection of objects of similar type Example: Object mango, apple, and orange is member of class fruit Object TF, TI, TK, TP is member of class Jurusan Object jip, sedan, bus, truk is member of class mobil

4 OBJECTS Is the variables of program Have a life cycle. They can be created and destroyed. Interacts by sending message to one another Contains data and code/ function to manipulate the data

5 CLASSES & OBJECTS SPECIFYING A CLASS class class_name { private: variable_declarations; function_declarations; public: variable_declarations; function_declarations; } Keywords private and public known as visibility labels. private can be accessed only from within the class. Data member/ Variable is commonly private. public can be accessed from outside the class. Member function is commonly public.

6 Class Private Area Public Area Data/ Variabel Function/ Method Data/ Variabel Function/ Method No Entry ! Entry Allowed

7 Konversi Prosedural ke OOP 1. Pastikan program sudah terbagi menjadi fungsi- fungsi/ modular. 2. Identifikasi class yang bisa dibuat. 3. Identifikasi data member dan member function untuk class yang bersangkutan. 4. Tentukan bagian private dan public class (sesuaikan dengan skenario fungsi utama). 5. Buat fungsi utamanya (void main()). a. Membuat obyek dari class. b. Menjalankan bagian public dari class.

8 //PROCEDURAL PROGRAMMING #include “stdio.h” void main() { int p, l, t, volume; printf(“Program Balok\n”); printf(“Masukkan P = “); scanf(“%d”, &p); printf(“Masukkan L = “); scanf(“%d”, &l); printf(“Masukkan T = “); scanf(“%d”, &t); volume = p * l * t; printf(“Volume = %d\n”, volume); } #include “iostream.h” class balok { private : int p, l, t, volume; public : void input(void) { printf(“Masukkan P = “); scanf(“%d”, &p); printf(“Masukkan L = “); scanf(“%d”, &l); printf(“Masukkan T = “); scanf(“%d”, &t); }; void hitung(void) { volume = p * l * t; }; void output(void) { printf(“Volume = %d\n”, volume); }; }; void main() {balok balokku; printf(“Program Balok\n”); balokku.input(); balokku.hitung(); balokku.output(); }

9 Constructors and Destructors Constructors Parameterized Constructors Multiple Constructors Constructors with Default Arguments Copy Constructors Destructors

10 Simple Constructor & destructor #include class coba {int kode; public : coba() {cout << "Kode = "<< kode << endl; cout << "konstruktor dijalankan...\n"; kode = 1; }; ~coba() { cout << "destruktor dijalankan...\n"; cout << "Kode = "<< kode << endl; }; void show() {cout << "Kode = "<< kode << endl; }; void main() { coba cobaku; cobaku.show(); }


Download ppt "Pertemuan 5 Review :: Kisi-kisi UTS ::. BASIC CONCEPTS OF OOP OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING."

Presentasi serupa


Iklan oleh Google