class commercialProperty{

}

class building{

}

class office extends building{

}

class retail extends building{

}

class space{

}

class suite extends space {

}



Does that sound about right thus far?

    Given the information provided, sure, that's about right.

      You may find it useful to use the base class's name as part of the child class's name, to avoid ambiguity later:

      class Building {
        private $spaces = array();
        public addSpace(Space $space) {
          $this->spaces[] = $space;
        }
      }
      
      class OfficeBuilding extends Building {
      }
      
      class Space {
      }
      
      class OfficeSpace extends Space {
      }
      
      $test = new OfficeBuilding();
      $test->addSpace(new OffcieSpace());
      
        NogDog;10997892 wrote:

        You may find it useful to use the base class's name as part of the child class's name, to avoid ambiguity later:

        class OfficeSpace extends Space {
        }
        

        Yeah so if you could just go ahead and do that from now on, that'd be greeeeat. Did you see the memo about this?

          No, not again. I... why does it say paper jam when there is no paper jam?

          class CommercialProperty{ 
          
          } 
          
          class Building{ 
          
          var $name;
          	var $size;
          	var $yearBuilt;
          	protected $spaces = array(); 
          
          public function addSpace(Space $space) { 
          $this->spaces[] = $space; 
          } 
          
          function __construct($name){
          	$this->name = $name;
          }
          
          function build($year){
          	$this->yearBuilt = $year;
          }
          
          function info(){
          	return $this->name . " was constructed in " . $this->yearBuilt . " and is approximately " . $this->size;
          }
          
          function countSpaces(){
          	return count($this->spaces);	
          }
          
          function __destruct(){
          
          }
          
          } 
          
          class OfficeBuilding extends Building{ 
          
          var $buildingClass;
          
          function combineSuites($suite1, $suite2){
          
          }
          
          function removeSuite($id){
          	unset($this->spaces[$id]);
          }
          
          function showSuites(){
          	return $this->spaces;
          }
          } 
          
          class RetailBuilding extends Building{ 
          
          } 
          
          class space{ 
          
          var $name;
          var $size;
          var $type;
          var $status;
          var $vacancy = true;
          
          
          function __construct($name){
          	$this->name = $name;
          }
          
          function lease(){
          	$this->vacancy = false;
          	$this->status = "leased";
          }
          
          function makeAvailable(){
          	$this->vacany = true;
          	$this->status = "available";
          }
          
          function removeFromMarket(){
          	$this->vacancy = true;
          	$this->status = "off market";
          }
          
          } 
          
          class OfficeSpace extends Space{
          
          }

            Hey Peter check out this chick on channel 9!

            Now you're getting it. Those are good simple classes.

              Pretty sure this is the best thread on this forum.

                I really want to pick this up... are there any good links to advanced OOP? or something you might actually use realistically. Everything I find is basic create an animal.. make it speak or similar.

                For example, I would like to create pdf flyers from the property object. But should I create a separate object for this or create a method in the property class?

                I guess what I'm looking for is steps you should take in planning out classes, creating a skeleton or layout, etc.?

                Any tips / help / links are greatly appreciated.

                <?php
                
                class Property{
                
                private $lotSize = 0;
                private $zoning = array();
                private $buildings = array();
                private $parkingLot;
                
                //Create New Property
                function __construct($size){
                	$this->lotSize = $size;
                }
                
                //Construct a Building on the Property
                function build(Building $name){
                	$this->buildings[] = $name;
                }
                //Construct Parking Lot on Site
                function pave($area, $spaces, $handicap=0){
                	$this->parkingLot = new ParkingLot($area, $spaces, $handicap);
                }
                //Assign Property Owner
                
                //If lot size is over 21,825 Square Feet (.5 Acres), Convert to Acres
                
                //Add Zoning
                	function addZoning($zone){
                		$this->zoning[] = $zone;
                	}
                //Remove Zoning
                	function removeZoning($zone){
                		unset($this->zoning[$zone]);
                	}
                }
                
                class CommercialProperty extends Property
                {
                
                }
                
                class ParkingLot
                {
                
                private $parking = 0;
                private $handicapParking = 0;
                
                //Create Parking Lot
                function __construct($area, $spots, $hc=0)
                {
                		$this->parking = $spots;
                		$this->handicapParking = $hc;
                }
                
                //Add Handicap Parking Spaces
                
                }
                
                class Building
                {
                
                public $name;
                private $elevators = 0;
                private $floors = 1;
                private $yearBuilt;
                
                //Construct Building
                function __construct($name, $year)
                {
                	$this->name = $name;
                	$this->yearBuilt = $year;
                }
                
                //Set Address
                
                //Assign Property Manager
                
                //Assign Broker
                
                }
                
                class CommercialBuilding extends Building
                {
                
                //Construct Commercial Building
                
                function __construct(){
                
                }
                
                }
                
                class OfficeBuilding extends CommercialBuilding
                {
                
                //Construct Office Building
                
                function __construct(){
                
                }
                
                //Add Office Suites
                
                //Combine Office Suites
                
                //Remove Office Suites
                
                }
                
                class RetailBuilding extends CommercialBuilding
                {
                
                //Construct Retail Building
                function __construct(){
                
                }
                
                }
                
                class Space
                {
                
                //Create Space
                function __construct(){
                
                }
                //Lease Space
                
                //Delete Space
                
                }
                
                class OfficeSpace extends Space
                {
                
                //Create Office Space
                
                //Lease Office Space
                
                //Delete Office Space
                
                }
                
                class RetailSpace extends Space
                {
                
                //Create Retail Space
                function __construct(){
                
                }
                //Lease Retail Space
                
                //Delete Retail Space
                
                }
                
                class Person{
                	//Create Person
                	function __construct(){
                
                }
                }
                
                class PropertyOwner extends Person
                {
                
                }
                
                class PropertyManager extends Person
                {
                
                }
                
                class Broker extends Person
                {
                
                }
                
                class Lease
                {
                
                //Create Lease
                function __construct(){
                
                }
                //Assign Lease
                
                //Un-Assign Lease
                
                //Renew Lease
                
                //Extend Lease
                
                //Break Lease
                
                //Delete Lease
                
                }
                
                ?>

                  PHP 5 Objects, Patterns, and Practice by Matt Zandstra helped me a lot.

                    NogDog;10997978 wrote:

                    PHP 5 Objects, Patterns, and Practice by Matt Zandstra helped me a lot.

                    The funny thing is, I went to Barnes & Noble last night to get that and they were out of stock. Ended up getting PHP 5.3 by Matt Doyle.. They just dont cover enough OOP in the basic books. :glare:

                      NogDog;10997978 wrote:

                      PHP 5 Objects, Patterns, and Practice by Matt Zandstra helped me a lot.

                      +1

                        Ok, so take the property class for example. I want the build method to construct an object based on building 'type':

                        $p = new Property('125856');
                        $office = $p->build('office');

                        so I would want the build method to be based on the passed variable in this (case 'office') to create the new building

                        function build($type){
                        		$building = new $type.Building();
                        		return $building;
                        	}

                        I know this is the wrong way to implement it. How would I do so and based on an array of building types so it can only create building types based on classes that already exist?

                          10 days later
                          NogDog;10997978 wrote:

                          PHP 5 Objects, Patterns, and Practice by Matt Zandstra helped me a lot.

                          fontener;10997980 wrote:

                          The funny thing is, I went to Barnes & Noble last night to get that and they were out of stock. Ended up getting PHP 5.3 by Matt Doyle.. They just dont cover enough OOP in the basic books. :glare:

                          I decided to check out this book and found it on Google Books for free, for anyone interested (3rd edition, too).

                            Any chance you could give a link to where you found it for free?

                              bradgrafelman;10999045 wrote:

                              Any chance you could give a link to where you found it for free?

                              Clickety clickety

                              I just searched for its ISBN (143022925X).

                                10 days later
                                fontener;10997980 wrote:

                                They just dont cover enough OOP in the basic books. :glare:

                                Perhaps because OO is not so much about P as it is about the whole process of software engineering?

                                (Do I sound like I've been reading Berard? )

                                If you have OOT, OORA/OORE, and OOD ... OOP just kind of follows, as long as you know the mechanics, right? 😃

                                  Write a Reply...