Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbserverprogrammering/exercises/classes/

classes.php
classes1.php
classes2.php
classes3.php
classes4.php
classes5.php

classes2.php

51 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Klasser 2</title>
</head>
<body>
  <?php
  
class Ball_b {
    
// Egenskaper
    
private $color;
    private 
$radius;

    
// Metoder
    
public function __construct($color$radius) {
      
$this->color $color;
      
$this->radius $radius;
    }
    public function 
get_color() {
      return 
$this->color;
    }
    public function 
get_radius() {
      return 
$this->radius;
    }
  }

  
$ball_1 = new Ball_b("Grön""1 dm");
  echo 
"Boll 1";
  echo 
"<hr style=\"border: none; border-top: 2px dotted black; width: 200px; margin-left: 0;\">";
  echo 
"Färg: " $ball_1->get_color() . "<br>";
  echo 
"Radie: " $ball_1->get_radius(). "<br>";
  echo 
"<hr style=\"width: 200px; margin-left: 0;\">" "<br>";

  
$ball_2 = new Ball_b("Röd""2 dm");
  echo 
"Boll 2";
  echo 
"<hr style=\"border: none; border-top: 2px dotted black; width: 200px; margin-left: 0;\">";
  echo 
"Färg: " $ball_2->get_color() . "<br>";
  echo 
"Radie: " $ball_2->get_radius(). "<br>";
  echo 
"<hr style=\"width: 200px; margin-left: 0;\">" "<br>";

  
$ball_3 = new Ball_b("Blå""4 dm");
  echo 
"Boll 3";
  echo 
"<hr style=\"border: none; border-top: 2px dotted black; width: 200px; margin-left: 0;\">";
  echo 
"Färg: " $ball_3->get_color() . "<br>";
  echo 
"Radie: " $ball_3->get_radius(). "<br>";
  echo 
"<hr style=\"width: 200px; margin-left: 0;\">" "<br>";
  
?>
 
</body>
</html>