<!--
    Brian Platz
    CS85 Section 1643
    Professor Geddes
    May 11, 2012
    Assignment: Test 3
    Data:
        Jeannie drives an absolute red 2007 Toyota Solara.
        Bill drives a burnt orange 1966 Chevrolet Corvette.
        Ken drives a pearl essence green 1966 Jaguar XKE.
        
        Part A (50 points)
            Write a PHP script called cars.php that defines a Car class, 
                creates three car objects as described above, 
                and outputs the state of each car object in a nice format. 
            Your class definition should have appropriate properties and methods, 
                including a method that outputs the current state of a car object. 
            Also, there should be methods for changing the state of an object. For example, 
                what if a car is painted a different color, or gets a new driver?

        Part B (20 points)
            Create an XML document called cars.xml that contains the data given above for the three cars.

        Part C (30 points)
            Write a SQL script called cars.sql.txt that 
                creates a cars table in the test3 database, 
                populates it with the data given above for the three cars, 
                and retrieves all the data, displaying it in ascending order by driver. 
                
                Note: You only have to write the script; you do NOT have to run it.
    --> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
      <title></title>
      <style type="text/css">
         body {background-color:#B0E0E6}
         h1 {color:black; font-family:Ariel; font-size:14pt; 
                 font-weight:bold; text-align: center}
         h2 {color:red; font-family:Ariel; font-size:14pt; font-weight:bold}
         h3 {color:black; font-family:Ariel; font-size:24pt; font-weight:normal}
         .center {margin-left: auto;
                    margin-right: auto;
                    width: 6em;}
      </style>    
   </head>
   <body> 
      <?php
          extract
($_REQUEST);                         // create form variables
          
error_reporting(E_ALL & ~E_NOTICE);         // get rid of runtime notices
          
      // Car Class definition    
          
class Car
               
{
                  private 
$year;        
               private 
$make;        
               private 
$model;    
               private 
$paint;
               private 
$driver;
        
               public function 
__construct($y$mk$md$p$d
               {
                       
$this->year $y;
                       
$this->make $mk;
                       
$this->model $md;
                       
$this->setPaint($p);
                       
$this->setDriver($d);
               }
               public function 
getYear()    // shouldn't change, so no set method
               
{
                       return 
$this->year;
               }
               
               public function 
getMake()    // shouldn't change, so no set method
               
{
                       return 
$this->make;
               }
               
               public function 
getModel()    // shouldn't change, so no set method
               
{
                       return 
$this->model;
               }
               
               public function 
getPaint()
               {
                       return 
$this->paint;
               }
               public function 
setPaint($new_color)
               {
                       
$this->paint $new_color;
               }
               
               public function 
getDriver()
               {
                       return 
$this->driver;
               }
               public function 
setDriver($new_driver)
               {
                       
$this->driver $new_driver;
               }
               public function 
state() 
               {
                       return 
$this->getDriver()." drives a ".$this->getPaint()." ".$this->getYear()." ".$this->getMake()." ".$this->getModel().".";
               }
              }
              
    
// create the 3 car objects
          
$car = array();
          
$car[] = new Car("2007""Toyata""Solara""absolute red""Jeannie");
          
$car[] = new Car("1966""Chevrolet""Corvette""burnt orange""Bill");
          
$car[] = new Car("1966""Jaguar""XKE""pearl essence green""Ken");
          
    
// print out state of the three cars
          
for ($i 0$i count($car); $i++) {
              print 
$car[$i]->state()."<br>";
              }
      
?>
<br>
<a href="../index.html#test3">Main Page</a>
   </body>
</html>