Chapter8 - Chapter 8 Introduction to Object-Oriented...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 8 Introduction to Object-Oriented Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Introduction Before we learned how to create procedures called functions and subroutines (modular programming). In this chapter we will introduce object- oriented programming. Object-oriented programming can be viewed, in simple terms, as an extension to modular programming.
Background image of page 2
3 Object-Oriented Programming Object-oriented programming is based on the idea that everything a program deals with is a object. An object is simply a code package that describes the properties of the thing that it represents and provides functionality to modify those properties.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Object-Oriented Programming Every form we have designed is an object. All graphical controls placed in a form – text boxes, buttons, check boxes – are objects as well. An object can represent tangible things such as a desk, a TV, a plane, a person or abstract concepts such as a bank account, a complex number or a math algorithm. An object is simply a code package that describes the properties of the thing that it represents and provides functionality to modify these properties.
Background image of page 4
5 Hierarchy of Visual Studio.NET Most of the programs we have created contained the following syntax: lblInfo.Text rbdCombo.Checked btnGo.Click Keys.Enter tbxNumber.Clear lbxNumbers.Items.Count
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Hierarchy of Visual Studio.NET One commonality between the syntax show previously is that they all follow the same pattern: item2.item1 or item3.item2.item1 This cascaded structure is typical of an object- oriented program. In item2.item1 , item2 is typically an object and item1 is a method property of that object.
Background image of page 6
7 Class Versus Object Object-oriented programming allows us to categorize, classify and present information in a structurally sound and robust way. The word class refers to the group that an object belongs to. There is only one TextBox class, but there can be many TextBox objects!
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Class Versus Object Objects belonging to the same group (class) share the same internal structure. For instance, every TextBox object has a text field, a text align field and the ability to clear its components (clear method) among many other things. This internal structure is defined in what is called a class definition .
Background image of page 8
9 Anatomy of an Object Class Let us assume that we want to create an application that keeps track of the performance of basketball players. A basketballPlayer class will probably include a name field, a fieldGoals field, a rebounds field, etc. Data members are variables that describe the characteristics of that class.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 BasketballPlayer Class Definition Class BasketballPlayer ‘ data members Private name As String Private fieldGoals As Double Private rebounds As Integer Private gamesPlayed As Integer End Class
Background image of page 10
11 Data Members (Member Variables) Every object contains its own copy of data members. If a program creates three BasketballPlayer
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2011 for the course COP 2271 taught by Professor Staff during the Fall '11 term at University of Florida.

Page1 / 43

Chapter8 - Chapter 8 Introduction to Object-Oriented...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online