Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
November 25, 2017, 12:29:41 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Question about Exercise 6  (Read 1286 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:  

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 ゥ 2009 classroomM.com. All rights reserved.