diff --git a/robot/img/bender.png b/robot/img/bender.png new file mode 100644 index 0000000..f4ee47c Binary files /dev/null and b/robot/img/bender.png differ diff --git a/robot/img/data.jpeg b/robot/img/data.jpeg new file mode 100644 index 0000000..0e17779 Binary files /dev/null and b/robot/img/data.jpeg differ diff --git a/robot/img/gort.png b/robot/img/gort.png new file mode 100644 index 0000000..d5bdd23 Binary files /dev/null and b/robot/img/gort.png differ diff --git a/robot/img/hal.png b/robot/img/hal.png new file mode 100644 index 0000000..f0b2506 Binary files /dev/null and b/robot/img/hal.png differ diff --git a/robot/img/johnny.png b/robot/img/johnny.png new file mode 100644 index 0000000..46e9d0a Binary files /dev/null and b/robot/img/johnny.png differ diff --git a/robot/img/optimus.png b/robot/img/optimus.png new file mode 100644 index 0000000..81c004c Binary files /dev/null and b/robot/img/optimus.png differ diff --git a/robot/img/rosey.jpeg b/robot/img/rosey.jpeg new file mode 100644 index 0000000..e2d5135 Binary files /dev/null and b/robot/img/rosey.jpeg differ diff --git a/robot/img/sico.jpeg b/robot/img/sico.jpeg new file mode 100644 index 0000000..53b739d Binary files /dev/null and b/robot/img/sico.jpeg differ diff --git a/robot/img/sonny.jpg b/robot/img/sonny.jpg new file mode 100644 index 0000000..34ced12 Binary files /dev/null and b/robot/img/sonny.jpg differ diff --git a/robot/img/twiki.jpg b/robot/img/twiki.jpg new file mode 100644 index 0000000..fe2730d Binary files /dev/null and b/robot/img/twiki.jpg differ diff --git a/robot/img/walle.png b/robot/img/walle.png new file mode 100644 index 0000000..3c6d83a Binary files /dev/null and b/robot/img/walle.png differ diff --git a/robot/index.php b/robot/index.php index f151142..deacbcb 100644 --- a/robot/index.php +++ b/robot/index.php @@ -4,17 +4,69 @@ class Robot private $model; private $color; private $os; + private $image; + private $size; + private $laws; - public function __construct($model, $color, $os) + public function __construct($model, $color, $os, $image, $size, $laws = '') { $this->set_model($model); $this->set_color($color); $this->set_os($os); + $this->set_image($image); + $this->set_size($size); + $this->set_laws($laws); } public function __toString() { - return '

Your ' . $this->get_color() . ' ' . $this->get_model() . ' running ' . $this->get_os() . ' will be built shortly. Thank you.

'; + $string = ' +
+
+ +
+
+

Your ' . $this->get_size() . ' sized ' . $this->get_color() . ' ' . $this->get_model() . ' running ' . $this->get_os() . ' will be built shortly. Thank you.

+
+
+ '; + + $laws = $this->get_laws(); + if (!empty($laws)) { + $string .= ' +

Your robot will obey the following laws:

+ + '; + } else { + $string .= '

Your robot has no rules.

'; + } + + $string .= ' +
+
+ '; + + return $string; } public function get_model() @@ -46,8 +98,52 @@ class Robot { $this->os = $os; } + + public function get_image() + { + return $this->image; + } + + public function set_image($image) + { + $this->image = $image; + } + + public function get_size() + { + return $this->size; + } + + public function set_size($size) + { + $this->size = $size; + } + + public function get_laws() + { + return $this->laws; + } + + public function set_laws($laws) + { + $this->laws = $laws; + } } +$models = [ + 'Sonny' => 'img/sonny.jpg', + 'Rosey' => 'img/rosey.jpeg', + 'SICO' => 'img/sico.jpeg', + 'Data' => 'img/data.jpeg', + 'Gort' => 'img/gort.png', + 'Wall-E' => 'img/walle.png', + 'Optimus Prime' => 'img/optimus.png', + 'Hal 9000' => 'img/hal.png', + 'Twiki' => 'img/twiki.jpg', + 'Bender' => 'img/bender.png', + 'Johnny 5' => 'img/johnny.png', +]; + ?> @@ -55,40 +151,235 @@ class Robot Robot - - +

I, Object

- 'A robot may not injure a human being or, through inaction, allow a human being to come to harm.', + 'second' => 'A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.', + 'third' => 'A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.', + ]; + $form = '
-
+ +
+
+
+
+
+
+ +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ + '; + + foreach ($laws as $key => $law) { + $form .= ' +
+ + + +
+

' . $law . '

+
+
+ '; + } + + $form .= ' +
+
@@ -146,10 +486,10 @@ function form() return $form; } -function message() +function message($models) { - if (isset($_POST['model']) && isset($_POST['color']) && isset($_POST['os'])) - $robot = new Robot($_POST['model'], $_POST['color'], $_POST['os']); + if (isset($_POST['model']) && isset($_POST['color']) && isset($_POST['os']) & isset($_POST['size'])) + $robot = new Robot($_POST['model'], $_POST['color'], $_POST['os'], $models[$_POST['model']], $_POST['size'], isset($_POST['laws']) ? $_POST['laws'] : ''); if (!$robot) return form(); @@ -162,13 +502,15 @@ function message()

Processing...

' . $robot->__toString() . ' -
+            
+
     ';
 
     $msg .= $dump;
 
     $msg .= '
-            
+
+
';