Amazon.com Widgets Ex 11-5 question.
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 01, 2014, 05:19:48 PM
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
| |-+ Answers to Exercises
| | |-+ Chapter 11
| | | |-+ Ex 11-5 question.
Pages: [1] Go Down
Print
Author Topic: Ex 11-5 question. (Read 578 times)
Nick Harvey
Newbie
*
Posts: 19






on: March 19, 2012, 11:11:37 PM

I have completed Exercise 11-5 to declare my Square class as a rectangle with some of the rectangle's methods (area and perimeter) and add those that pertain to a square (side, setSide and initWithSide).

This removes access to all of the other methods I have written for the Rectangle class including ones used in my XYPoint and GraphicObject classes.

What I really need in my Square class is to inherit all methods from my Rectangle class and only disable those Rectangle methods that are not applicable to a square (initWithWidth andHeight, setWidth andHeight). All other Rectangle methods I have are applicable to a Square.

I can declare all Rectangle methods (and XYPoint and GraphicObject methods) I need in my Square class but this seems like a lot of work to effectively disable two Rectangle methods that do not apply for a Square.

Is there a way to do this: declare a subclass and disable some inherited methods that do not apply?
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.