Amazon.com Widgets Question about Exercise 6
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 28, 2014, 05:01:55 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 3 - Classes, Objects, and Methods
| | | |-+ Question about Exercise 6
Pages: [1] Go Down
Print
Author Topic: Question about Exercise 6 (Read 627 times)
Cloaky
Newbie
*
Posts: 4






on: December 15, 2011, 12:43:09 PM

Quote
In a procedural language such as C, you think about actions and then write code to perform the action on various objects. Referring to the car example, you might write a procedure in C to wash a vehicle and then inside that procedure write code to handle washing a car, washing a boat, washing a motorcycle, and so on. If you took that approach and then wanted to add a new vehicle type (see the previous exercise), do you see advantages or disadvantages to using this procedural approach over an object-oriented approach?

The correct answer would be no, right? The best way to do it would be to create a class for each vehicle, or even a main class with a subclass for each specific vehicle. To add a new vehicle i would just need to implement a new subclass! The events, in each class, could essentially have the same name if i take advantage of the Polymorphism concept. I am right?

Thanks.
Last Edit: December 15, 2011, 12:45:14 PM by Cloaky Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.