Download presentation
Presentation is loading. Please wait.
1
Object Oriented Programming.
Kwangwoo Choi Department of Physics Kangwon National University Object Something perceptible by one or more of the senses, especially by vision or touch; a material thing. 2. OOP(Object Oriented Programming) 3. Abstract 4. Class 5. encapsulation 6. inheritance 7. polymorphism
2
noun : accountNum, password , restMoney, interest
object name : account noun : accountNum, password , restMoney, interest verb: saveMoney , withdrawMoney , getRestMoney public class Account { private String accountNum = " "; private String password = " "; private long restMoney = ; private float interest = 3.34F; public void saveMoney(long amount) { restMoney = restMoney + amount; } public void withdrawMoney(long amount) { restMoney = restMoney - amount; } public long getRestMoney() { return restMoney; public void setInterest(float newInterest) { interest = newInterest; }
3
Make Object Account x; x = new Account(); Account x= new Account()
public class Bank { public static void main(String [] args) { Account x = new Account(); x.saveMoney(100); x.withdrawMoney(50); System.out.println(x.getRestMoney()); } }
4
Encapsulation private String creaditCardNo; // private member
public class Encapsulation { private String creaditCardNo; // private member public void setCreaditCardNo(String str) { creaditCardNo = str; } public String getCreaditCardNo() { return creaditCardNo; } } • public • protected • default • private
5
Inheritance class Employee { String name; Date hireDate;
Date dateOfBirth; } class Manager { String name; Date hireDate; Date dateOfBirth; String department; Employee subordinamtes []; class Employee { String name; Date hireDate; Date dateOfBirth; } class Manager extends Employee{ String department; Employee subordinamtes []; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.