Csharp_Ch4_PPT0 - C# 2010 for Programmers Chapter 4 Dr....

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

View Full Document Right Arrow Icon
C# 2010 for Programmers Chapter 4 Dr. Meng-Hung Wu
Background image of page 1

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

View Full DocumentRight Arrow Icon
Object-Oriented Programming Object-oriented programming is centered on creating objects rather than procedures. Objects are a melding of data and procedures that manipulate that data. Data in an object are known as attributes . Procedures in an object are known as methods .
Background image of page 2
Object-Oriented Programming Object Data (Attributes) Methods That Operate on the Data
Background image of page 3

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

View Full DocumentRight Arrow Icon
Object-Oriented Programming Object Data (Attributes) typically private to this object Methods That Operate on the Data Code Outside the Object
Background image of page 4
Object-Oriented Programming Code Reusability Object-Oriented Programming (OOP) has encouraged object reusability. A software object contains data and methods that represents a specific concept or service. An object is not a stand-alone program. Objects can be used by programs that need the object’s service. Reuse of code promotes the rapid development of larger software projects.
Background image of page 5

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

View Full DocumentRight Arrow Icon
An Everyday Example of an Object—An Alarm Clock Attributes define the state that the alarm is currently in. The current second (a value in the range of 0-59) The current minute (a value in the range of 0-59) The current hour (a value in the range of 1-12) The time the alarm is set for (a valid hour and minute) Whether the alarm is on or off (“on” or “off”)
Background image of page 6
An Everyday Example of an Object—An Alarm Clock Methods are used to change a attribute’s value Set time Set alarm time Turn alarm on Turn alarm off Increment the current second Increment the current minute Increment the current hour Sound alarm Public methods are accessed by users outside the object. Private methods are part of the object’s internal design.
Background image of page 7

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

View Full DocumentRight Arrow Icon
Classes and Objects The programmer determines the attributes and methods needed, and then creates a class. A class can specify the attributes and methods that a particular type of object may have. A class is a “blueprint” that objects may be created from. A class is not an object, but it can be a description of an object. An object created from a class is called an instance of the class.
Background image of page 8
Classes and Objects Insect class The Insect class defines the attributes and methods that will exist in all objects that are an instances of the Insect class. housefly object The housefly object is an instance of the Insect class. mosquito object The mosquito object is an instance of the Insect 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
Classes From chapter 2, we learned that a reference variable contains the address of an object. string cityName = “Charleston”; Charleston Address to the object cityName The object that contains the character string “Charleston”
Background image of page 10
The Length property of the string class returns and integer value that is equal to the length of the string. int stringLength = cityName.Length;
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 03/28/2011 for the course CIT 2422 taught by Professor W during the Spring '11 term at South Texas College.

Page1 / 62

Csharp_Ch4_PPT0 - C# 2010 for Programmers Chapter 4 Dr....

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