?php
/*
I have a question here regarding object orientation in PHP and any other
language.
Let's start with some hypothetical code:
*/
// --- 1st CLASS
class ParkingLot {
var size; // size in sq feet
var max_number_of_cars; // how many cars there is space for
function __construct($size,
On Fri, 2008-07-11 at 18:03 +0200, Yeti wrote:
?php
/*
I have a question here regarding object orientation in PHP and any other
language.
Let's start with some hypothetical code:
*/
// --- 1st CLASS
class ParkingLot {
var size; // size in sq feet
var max_number_of_cars;
Object-oriented programming, with it's class and object approach,
is meant to model real life more closely than functional programming.
In, a parking space is physically inside a parking lot, but a
parking space is not a subclass of a parking lot. It's not a variation
or mini parking
Corrected code example:
(too early in the morning to think)
?php
class ParkingLot {
var $size;
var $num_spaces;
var $spaces = array();
}
class ParkingSpace {
var $ps_ID;
var $occupied_by;
var $st_time;
}
?
In the above class definition, simply populate the $spaces array
On Fri, Jul 11, 2008 at 12:03 PM, Yeti [EMAIL PROTECTED] wrote:
?php
/*
I have a question here regarding object orientation in PHP and any other
language.
Let's start with some hypothetical code:
*/
// --- 1st CLASS
class ParkingLot {
var size; // size in sq feet
var
-- Forwarded message --
From: Yeti [EMAIL PROTECTED]
Date: Fri, Jul 11, 2008 at 2:08 PM
Subject: Re: [PHP] Question regarding OO
To: Eric Butera [EMAIL PROTECTED]
I understand my error in thinking now.
Apple can't extend Tree.
Oak, Evergreen or Willow extend Tree.
I thank you
[snip]
I understand my error in thinking now.
Apple can't extend Tree.
Oak, Evergreen or Willow extend Tree.
I thank you all for helping me to understand.
[/snip]
By jove, I think he's got it!
Parking space could be a member variable of parking lot, that would make
sense.
--
PHP General
-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2008 1:51 PM
To: Eric Butera; php php
Subject: RE: [PHP] Question regarding OO
[snip]
I understand my error in thinking now.
Apple can't extend Tree.
Oak, Evergreen or Willow extend Tree
8 matches
Mail list logo