1 / 8

Object Oriented Programming

Object Oriented Programming. ICS3/4. Why OOP?. In the past, all of your programs have been “ procedural programs ” . Use loops, decision statements etc. to solve problems

Download Presentation

Object Oriented Programming

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Programming ICS3/4

  2. Why OOP? • In the past, all of your programs have been “procedural programs”. • Use loops, decision statements etc. to solve problems • PROBLEM: It is not always easy to take real life situations and program them using simple variables (int, double, boolean, string) • The focus is on solving tasks

  3. Why OOP? • Object Oriented programming is a new paradigm • We focus on data objects and relationships among them • Think of data as active – it does things (instead of having things done to it) • Your programs become a collect of objects that cooperate and share information between them • Eg. Several factories work together to make the parts for building a car

  4. Classes • In OOP, classes are blueprints for creating objects • Defines what properties an object has • Defines what actions the object can perform or have performed on it • Classes define the way objects look and behave.

  5. Lets look at a sample class • The fraction class • Instance variables • Private vs. public • Information hiding • The Constructor • Methods • Setter and getters

  6. Why Use Objects? • Clarity • Reusability • Customizable • Create your own data types and control how they are used • Excellent for simulations of real life situations • Eg. Simulate the effects on traffic of shutting down the 401

  7. Your task • Create a class for representing students in a school administration program • What properties does a student have? • What can it do? (in the context of our program) • Test your class by creating student objects and manipulating them

More Related