chapter 7 object oriented programing n.
Download
Skip this Video
Download Presentation
Chapter 7 Object-Oriented Programing

Loading in 2 Seconds...

play fullscreen
1 / 8

Chapter 7 Object-Oriented Programing - PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on

Chapter 7 Object-Oriented Programing. Lecturer: Ty Rasmey Email:rasmeyt2@gmail.com. Overview. OOP Classes Objects Constructor Accessing an Object’s Data and Methods. Object-Oriented Programming. What is OOP? Modelling real-world object in software Why design application in this way?

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 7 Object-Oriented Programing' - ashely-freeman


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 7 object oriented programing

Chapter 7Object-Oriented Programing

Lecturer: Ty Rasmey

Email:rasmeyt2@gmail.com

overview
Overview
  • OOP
  • Classes
  • Objects
  • Constructor
  • Accessing an Object’s Data and Methods
object oriented programming
Object-Oriented Programming
  • What is OOP?
    • Modelling real-world object in software
    • Why design application in this way?
      • We naturally classify objects into different types
      • By attempting to do this with software aim to make it more

maintainable, understandable, easier to reuse

    • Other Programming: C++, C#, VB .NET, ActionScript, Ruby etc. also use OOP.
  • 3 Concepts of OOP
    • Class Encapsulation; protects and manages own information
    • Class Inheritance; software reuse
    • Polymorphism
class 1
Class(1)
  • What is Class?
    • Class is a template or blueprint or model
    • A class creates many objects
class 2
Class(2)
  • In a class, there are:
    • State; data field(also known as Properties)
    • Behaviour:
      • Constructors
      • Methods

public class Student {

private int id, String name;

public Student(){}

public Student (int inputID,

String inputName){

this.id = inputID;

this.name = inputName;

}

public String toString(){

return id + name;

}

}

constructor 1
Constructor(1)
  • What is Constructor?
    • A constructor to construct objects from a class

public class Student {

private int id, String name;

public Student(){}

public Student (int inputID,String inputName){

this.id = inputID;

this.name = inputName;

}

public String toString(){

return id + name;

}

}

constructor 2
Constructor(2)
  • How to construct objects?
    • Usually, we have many classes in a projects. So the student

class will be created in other classes.

    • To construct objects from student class:

public class TestStudent {

public static void main(String[] args){

Student stu;

//To construct an object

stu = new Student();

System.out.println(stu.toString());

}

}

accessing an object s data and methods
Accessing an Object’s Data and Methods
  • To access method:

public class TestStudent {

public static void main(String[] args){

Student stu;

//To construct an object

stu = new Student(123,”Veasna”);

System.out.println(stu.toString());

}

}

  • To access data:
    • Usually, We don’t access the data. If you like, you can do like : stu.id = 123in case id is not private.