Chapter 6 introduces you to object-oriented programming. The topics discussed in this chapter are: Object-oriented programming overview, UML class diagram, first OOP class, private and public access, driver class, reference variables and instantiation, calling a method, calling object. | Chapter 6 - Object-Oriented Programming Object-oriented programming overview objects classes encapsulation UML Class Diagram First OOP Class private and public Access Driver Class Reference Variables and Instantiation Calling a Method Calling Object 1 The this Reference Default Values Variable Persistence OOP Tracing Procedure (hidden) UML Class Diagram for Next Version of the Mouse Program Local Variables return statement void Return Type Empty return Statement Argument Passing Specialized methods: accessor methods mutator methods boolean methods Chapter 6 - Object-Oriented Programming 2 Object-Oriented Programming Overview In the old days, the standard programming technique was called "procedural programming." That's because the emphasis was on the procedures or tasks that made up a program. You'd design your program around what you thought were the key procedures. Today, the most popular programming technique is object-oriented programming (OOP). With OOP, instead of thinking first about procedures, you think first about the things in your problem. The things are called objects. 3 Object-Oriented Programming Overview An object is: A set of related data which identifies the current state of the object. + a set of behaviors Example objects: Car object in a traffic-flow simulation: data = ? methods = ? human entities physical objects mathematical entities employees cars in a traffic-flow simulation points in a coordinate system customers aircraft in an air-traffic control system complex numbers students electrical components in a circuit-design program time 4 Object-Oriented Programming Overview Benefits of OOP: Programs are more understandable - Since people tend to think about problems in terms of objects, it's easier for people to understand a program that's split into objects. Fewer errors - Since objects provide encapsulation (isolation) for the data, it's harder for the data to get messed up. 5 Object-Oriented Programming Overview A class | Chapter 6 - Object-Oriented Programming Object-oriented programming overview objects classes encapsulation UML Class Diagram First OOP Class private and public Access Driver Class Reference Variables and Instantiation Calling a Method Calling Object 1 The this Reference Default Values Variable Persistence OOP Tracing Procedure (hidden) UML Class Diagram for Next Version of the Mouse Program Local Variables return statement void Return Type Empty return Statement Argument Passing Specialized methods: accessor methods mutator methods boolean methods Chapter 6 - Object-Oriented Programming 2 Object-Oriented Programming Overview In the old days, the standard programming technique was called "procedural programming." That's because the emphasis was on the procedures or tasks that made up a program. You'd design your program around what you thought were the key procedures. Today, the most popular programming technique is object-oriented programming (OOP). With OOP, instead of .