Restaurant.php - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Restaurant.php.php
- <?php
- // Restaurant.php
- class Restaurant {
- public $name;
- public $menu;
- public $inventory;
- public $funds;
- public function __construct($name) {
- $this->name = $name;
- $this->menu = [];
- $this->inventory = [];
- $this->funds = 1000;
- }
- public function addMenuItem($name, $price, $ingredients) {
- $this->menu[] = new MenuItem($name, $price, $ingredients);
- }
- public function buyIngredients($ingredients) {
- // Check funds are sufficient
- // Pay for ingredients
- // Add to inventory
- }
- public function cookItem($item) {
- // Check ingredients are in inventory
- // Deduct ingredients used
- // Add completed dish to inventory
- }
- // More functions for selling dishes, hiring staff, upgrades etc..
- }
- // MenuItem.php
- class MenuItem {
- public $name;
- public $price;
- public $ingredients;
- public function __construct($name, $price, $ingredients) {
- // Constructor
- }
- }
- ?>