Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

size = $new _ size; } public function set _ type ( $new _ type ) { $this - > type = $new _ type;

size = $new_size;
}
public function set_type($new_type){
$this->type = $new_type;
}
}
/*03: Add get_size and get_type methods to the Pizza class
above. This problem has no output.
*/
/*04: Create a $pizza object from the Pizza class.
Create the $pizza object just below this problem.
This problem has no output.
*/
/*05: Set the $pizza size to "medium".
You can do this just below this problem.
This problem has no output.
*/
$pizza->set_size("medium");
/*06: Set the $pizza type to "Pepperoni".
You can do this just below this problem.
This problem has no output.
*/
$pizza->set_type("pepperoni");
/*06: Call the get_size method and output the
returned value in appropriate HTML list item below. */
public function getSize(){
return $this->size;
}
/*07: Call the get_type method and output the
returned value in appropriate HTML list item below. */
public function getType(){
return $this->type;
}
/*08: Add a method to the Pizza class above named serve.
The serve method should output:
"Here's your {type} pizza!"
Replace {type} with the value of the type
property.
Call the serve method and output the
returned value in appropriate HTML list item below.
*/
public function serve(){
return "Here's your {$this->type} pizza!";
}
/*09: Add a private property named
slices to the Pizza class above.
Next, add a method named get_slices
to the Pizza class.
The method should return the number
of slices.
A small pizza has 6 slices.
A medium pizza has 8 slices.
A large pizza has 10 slices.
Set the value of the private slices
property when the size is set.
Call the get_slices method and
output the returned value in
appropriate HTML list item below.
*/
public function getSlices(){
return $this->slices;
}
private function setSlices(){
switch ($this->size){
case 'small':
$this->slices =6;
break;
case 'medium':
$this->slices =8;
break;
case 'large':
$this->slices =10;
break;
default:
$this->slices =8; // default to medium size
}
}
/*10: Add a method named description
to the Pizza class above.
The method should return:
"My pizza is a {size}{type} and
has {slices} slices!"
Replace {slices} with the number of slices.
Replace {size} and {type} with their
appropriate values.
Create a $myPizza object.
Set the size to "large".
Set the type to "Supreme".
Call the description method for $myPizza
and output the returned value in
appropriate HTML list item below.
?>*/
public function description(){
return "My pizza is a {$this->size}{$this->type} and has {$this->slices} slices!";
}
public function description(){
return "My pizza is a {$this->size}{$this->type} and has {$this->slices} slices!";
}
?>
INF653 Practice 04
Your output should only be in the ordered list below.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Identify examples of quantitative research.

Answered: 1 week ago