In a separate PHP file, code the class definition for a "Car" object. Name this
file something like carClass.php.
Make sure your "Car" class has these features:
A constructor function that sets a default car model of "Edsel", and
a default color of "bubblegum".
A function setModel( ) that allows the programmer to change
the car's model.
A function getModel( ) that allows the programmer to retrieve (get)
the car's model.
A function setColor( ) that allows the programmer to change
the car's color.
A function getColor( ) that allows the programmer to retrieve (get)
the car's color.
This separate PHP file will be used as an "include" file in the PHP action
page (see step 6, below).
Make an "About Us" page for your class Web site. Name it aboutus.php.
Put an HTML form on your About Us page, which allows the user to pick a car model and color. This
means that you will have two items that the user can enter or select:
Model
Color
The "model" and "color" choices can be text entry boxes, or radio buttons, or select lists; this
is your option and your choice.
Also put the action code into your About Us page.
You will need to
"include" the PHP "Car" class page that you made in step 3, in your
About Us page.
If the form has NOT been submitted yet,
in the action code in the About Us page create a "Car" object.
Don't put any arguments in the Car() function call when
you create
your instance of the "Car" class/object.
If the form HAS been submitted (meaning that the user has selected
or entered
a new model and color for their car
and has clicked the submit button),
create a "Car" object and use the FORM values that the user selected
or entered as the arguments in the
Car() function call when
you create
your instance of the "Car" class/object. (Alternatively, you could create
the "Car" object with no arguments, but then use the object's "Set" methods
to change the model and color.)
Immediately after you create the "Car" object in both cases given above, display the object's
model and color properties in your About Us page. Use the "get" functions to retrieve these
values.
Upload your pages to your class Web site server.
Test your page
by clicking your student number on the
"Student Sites" page of this class site. Display your About Us page. Test the form and "Car"
code.
HINT:
You can have more than one default parameter in the constructor
function. You need to separate multiple parameters with commas.