02-12-2008, 01:49 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Posts: 25
Thanks: 8
|
Interface Question
Hello,
A friend of mine sent me this question and we had different views on how to approach/solve it. So, I am hoping that some of the PHP Gurus here might be able to throw some light on this:
So here it Goes:
Class Diagram
Container-----Bag
|
|
|
Luggage
Vehicle
|
|
Car ----Station Wagon
|
Sports
Basically what needs to achieved is: Define the Vehicle interface with an abstract ‘addLuggage’ function that takes a Container as argument.
Define the Car class that initialises an array of luggage upon instantiation.
Define the Sports class with an implementation of the ‘addLuggage’ function that throws an exception if a Suitcase is passed as argument.
So, how would you approach it?
|
|
|
|