OOP_1_TEG

18
Object Oriented Programming TeguhSutanto Si | STIKOM Surabaya [email protected]|+628563076813|http://teguhsutanto.blogspot.com| http://blog.stikom.edu/teguh

Transcript of OOP_1_TEG

Page 1: OOP_1_TEG

Object Oriented Programming

TeguhSutanto Si | STIKOM Surabaya

[email protected]|+628563076813|http://teguhsutanto.blogspot.com|http://blog.stikom.edu/teguh

Page 2: OOP_1_TEG

GOAL

1.Students can understand the Object Oriented Programming concepts

2.Students can make a program in accordance with the rules of Object Oriented Programming

Page 3: OOP_1_TEG
Page 4: OOP_1_TEG

Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields

and methods together with their interactions –

to design applications and computer programs

Page 5: OOP_1_TEG

Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and

data rather than logic. Historically, a program has been viewed as a logical

procedure that takes input data, processes it, and produces output data

Page 6: OOP_1_TEG

Why OOP?

1.Object-oriented systems can be easily upgraded from small to large scale.

2. It is easy to partition the work in a project based on objects.

3.Object-oriented programming offers a new and powerful model for writing computer software.

4. It reduces software maintenance and developing costs.

5.Changes in user requirements or later developments have always been a major problem.

6.Object-orientation or object oriented programming (OOP) should help one in developing high quality software easily.

Page 7: OOP_1_TEG

Concept of Class and Object

• “Class” refers to a blueprint. It defines the variables and methods the objects support

• “Object” is an instance of a class. Each object has a class which defines its data and behavior

Page 8: OOP_1_TEG

Concept of Class and Object

Page 9: OOP_1_TEG

Classes reflect concepts, objects reflect instances that embody those

concepts

Daria JaneBrittany

Jodie

girlclassobject

Page 10: OOP_1_TEG
Page 11: OOP_1_TEG
Page 12: OOP_1_TEG

Class:A class can have three kinds of members:

Page 13: OOP_1_TEG

Attribute/Field/Data

Method

Page 14: OOP_1_TEG

Field Declaration

• a type name followed by the field name, and optionally an initialization clause

• primitive data type vs. Object referenceo boolean, char, byte, short, int, long, float,

double• field declarations can be preceded by

different modifierso access control modifierso statico final

Page 15: OOP_1_TEG

Acces Control Modifier

1.private: private members are accessible only in the class itself

2.package: package members are accessible in classes in the same package and the class itself

3.protected: protected members are accessible in classes in the same package, in subclasses of the class, and in the class itself

4.public: public members are accessible anywhere the class is accessible

Page 16: OOP_1_TEG

comPerson

• name: String• address: String

# age: int+getName(): String

Employee HRD

X

MainMenuX

Page 17: OOP_1_TEG

public class Pencil {public String color = “red”;public int length;public float diameter;private float price; public static long nextID = 0; public void setPrice (float newPrice) { price = newPrice; } }

public class CreatePencil {public static void main (String args[]){Pencil p1 = new Pencil();p1.price = 0.5f; }

}

Pencil.java

CreatePencil.java

%> javac Pencil.java%> javac CreatePencil.javaCreatePencil.java:4: price has private access in Pencilp1.price = 0.5f;^

Page 18: OOP_1_TEG