Lecture 2 Object-oriented Programming Concepts Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.

Slides:



Advertisements
Presentasi serupa
Konsep OOP di Java TRASPAC, Mei 2009 Oleh : Siwi Arie Widadi.
Advertisements

TURUNAN/ DIFERENSIAL.
Java Fundamentals: 5. Java Advanced
Pemrograman JAVA (TIB09)
CARI ERROR !!! ADA BERAPA KESALAHAN ??? Apa beda JRE dan JDK ??? JDK JRE.
Malang,22 November 2012
Pemrograman Berorientasi Objek
Membuat class sendiri.
Algoritma dan Struktur Data
Array.
Other OOP Basic Viska Mutiawani, M.Sc. Konsep penting Method overloading Encapsulation this keyword final static.
Dictionary (Icomparable dan IComparer) Eka, Erick, Reddy © Sekolah Tinggi Teknik Surabaya 1.
Abstract Class & Interface
LIMIT FUNGSI LIMIT FUNGSI ALJABAR.
TURUNAN DIFERENSIAL Pertemuan ke
Workshop SCS: Java Game Programming
Pemrograman Berorientasi Objek
Oleh : Sukma Murdani, S.Kom. SILABUS PENDAHULUAN Pengenalan OOP Pengenalan JAVA OOP (Object Oriented Programming) JAVA Class, Java Interface Encapsulation.
Luas Daerah ( Integral ).
Lecture 2 Introduction to C# - Object Oriented Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Modul 1- Review Java.
Lecture 9 Single Linked List Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
KONTROL ALUR EKSEKUSI PROGRAM
SLIDE OTOMATIS PINDAH DALAM WAKTU 4-5 MENIT. A:kiriB:kanan Deklarasikan sebuah variabel dengan nama ‘isi’ yang mempunyai type array of double dengan ukuran.
INHERITANCE.
Method.
1 OOAD Classes. 2 Diagram Kelas Diagram kelas digunakan untuk: Memodelkan vocabulary sistem: menggambarkan abstraksi-abstraksi yang terdapat pada sistem.
INTERFACE & ABSTRACT CLASS
ITK-121 KALKULUS I 3 SKS Dicky Dermawan
Struktur Kontrol.
Advanced Class 2 Pertemuan 11 Pemrograman Berbasis Obyek Oleh Tita Karlita.
Pemrograman Berbasis Obyek
Pertemuan 8 Pemrograman Berbasis Obyek Oleh Tita Karlita
I/O Stream lanjutan.
Encapsulation, Inheritance, polymorphism, dan interface
Variabel, Method & Constructor Oleh : Nur Hayatin, S.ST Teknik Informatika – UMM 2011.
INHERITANCE, POLYMORPHISM, DAN INTERFACE
Pemrograman Berorientasi Obyek Oleh Tita Karlita
Review :: Kisi-kisi UTS ::
WISNU HENDRO MARTONO,M.Sc
METHOD Object Oriented Programming with JAVA 2011/2012.
Pertemuan : Object Oriented Programming
OBJECT ORIENTED PROGRAMMING YANES HARDIANTO SUI Politeknik Manufaktur Astra 2011.
07 Advanced Class Features
Bekerja dengan Java class library
Object Oriented Programming with JAVA 2011/2012
INTERFACE & ABSTRACT CLASS Object Oriented Programming with JAVA 2011/2012.
Class and Object Introduction Specifying a Class Defining Member Function A C++ Program with Class Nesting of Member Functions Private Member Functions.
Public class RelasiDemo { public static void main(String[] args) { //beberapa nilai int i = 37; int j = 42; int k = 42; System.out.println("Nilai variabel...");
Inheritance Matakuliah : T0984 / Algoritma dan Metode Object Oriented Programming II Pertemuan : 4 Tahun : 2008 Versi : 1/0.
Inheritance, polymorphism, dan interface
Kelas Lanjut 2 Oleh Tita Karlita.
Class and Object Matakuliah : XXXX / Algoritma dan Metode Object Oriented Programming II Pertemuan : 2 Tahun : 2008 Versi : 1/0.
INHERITANCE (Oleh : Nur Hayatin, S.ST)
METHOD, ARRAY DAN STRING
OOP Java Minggu 2b Dasar OOP. Class (1) Deklarasi class : [ *] class { [ *] } Cat : [] = optional, * = repeat 0-N.
Pertemuan 6 PEWARISAN AND POLYMORPHISM
Bayu Priyambadha, S.Kom.  Classes, which are the "blueprints" for an object and are the actual code that defines the properties and methods.  Objects,
Bahasa Pemrograman (Pemrograman Visual)
FONDASI PEMROGRAMAN & STRUKTUR DATA #5
Enkapsulasi.
Constructor dan Overloading
Constructor overloading
Association, Composition dan Inheritance
CLASS Pertemuan 003.
Membuat Kelas.
PBO Lanjutan Membuat Kelas.
Pertemuan 4 Praktek Pembuatan Program Class dan Objek (Lanjutan)
Bahasa Pemrograman (Pemrograman Visual)
FONDASI PEMROGRAMAN & STRUKTUR DATA #4 - 1
Transcript presentasi:

Lecture 2 Object-oriented Programming Concepts Erick Pranata © Sekolah Tinggi Teknik Surabaya 1

» Object » Class » Inheritance » Technical Details 2 © Sekolah Tinggi Teknik Surabaya

3

4

5

» Modularity » Information-hiding » Code re-use » Pluggability and debugging ease 6 © Sekolah Tinggi Teknik Surabaya

7

A class is a blueprint or prototype from which objects are created 8 © Sekolah Tinggi Teknik Surabaya

class Bicycle { int cadence = 0; int speed = 0; int gear = 1; void changeCadence(int newValue) { cadence = newValue; } 9 © Sekolah Tinggi Teknik Surabaya

void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:" + cadence + " speed:" + speed + " gear:" + gear); } 10 © Sekolah Tinggi Teknik Surabaya

class BicycleDemo { public static void main(String[] args) { Bicycle bike1 = new Bicycle(); Bicycle bike2 = new Bicycle(); bike1.changeCadence(50); bike1.speedUp(10); bike1.changeGear(2); bike1.printStates(); bike2.changeCadence(50); bike2.speedUp(10); bike2.changeGear(2); bike2.changeCadence(40); bike2.speedUp(10); bike2.changeGear(3); bike2.printStates(); } 11 © Sekolah Tinggi Teknik Surabaya

12

13 © Sekolah Tinggi Teknik Surabaya

class MountainBike extends Bicycle { // new fields and methods defining // a mountain bike would go here } 14 © Sekolah Tinggi Teknik Surabaya

15

class MyClass extends MySuperClass implements YourInterface { // field, constructor, and // method declarations } 16 © Sekolah Tinggi Teknik Surabaya

» Class, Field, Constructor, Method 17 © Sekolah Tinggi Teknik Surabaya ModifierClassPackageSubclassWorld publicYYYY protectedYYYN no modifierYYNN privateYNNN

public class DataArtist {... public void draw(String s) {... } public void draw(int i) {... } public void draw(double f) {... } public void draw(int i, double f) {... } 18 © Sekolah Tinggi Teknik Surabaya

» Every class can have more than one constructor (overloading constructor) public Bicycle( int startCadence, int startSpeed, int startGear ) { gear = startGear; cadence = startCadence; speed = startSpeed; } public Bicycle() { gear = 1; cadence = 10; speed = 0; } 19 © Sekolah Tinggi Teknik Surabaya

public Polygon polygonFrom(Point... corners){ int numberOfSides = corners.length; double squareOfSide1, lengthOfSide1; squareOfSide1 = (corners[1].x -corners[0].x) * (corners[1].x - corners[0].x) + (corners[1].y - corners[0].y) * (corners[1].y - corners[0].y); lengthOfSide1 = Math.sqrt(squareOfSide1); // more method body code follows that // creates and returns a polygon // connecting the Points } 20 © Sekolah Tinggi Teknik Surabaya

Point originOne = new Point(23, 94); 21 © Sekolah Tinggi Teknik Surabaya

Rectangle rectOne = new Rectangle(originOne, 100, 200); 22 © Sekolah Tinggi Teknik Surabaya

» Methods can return value ˃Primitive Data Type ˃Object Point getPoint() { return new Point(5,8); } 23 © Sekolah Tinggi Teknik Surabaya

public class Bicycle { private int cadence; private int gear; private int speed; // add an instance variable for the object ID private int id; // add a class variable for the // number of Bicycle objects instantiated private static int numberOfBicycles = 0; } » Can also be “class method” 24 © Sekolah Tinggi Teknik Surabaya

» Object-oriented Programming Concepts, ava/concepts/object.html ava/concepts/object.html 25 © Sekolah Tinggi Teknik Surabaya

26

» Create Class Mahasiswa » Instantiate Mahasiswa » Manipulate beberapa object Mahasiswa (Reference Concept) » Asisten, inherit Mahasiswa 27 © Sekolah Tinggi Teknik Surabaya