Example #1
4
 public static function displayPagina($accion)
 {
     $coche = new Coche();
     if ($accion == "guardar") {
         $coche->guardarInfo();
     } elseif ($accion == "eliminar") {
         $coche->olvidarInfo();
     }
     if (isset($_COOKIE["cookieCoche"])) {
         self::_displaySalida();
     } else {
         self::_displayForm();
     }
 }
Example #2
0
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
    <?php 
include_once 'Vehiculo.php';
include_once 'Coche.php';
include_once 'Bicicleta.php';
$cocheDeLuis = new Coche("Saab", "93", "rojo");
$cocheDeJuanK = new Coche("Toyota", "Avensis", "verde");
$bicicletaJulieta = new Bicicleta("BTWIN", "RockRider 300", "2013");
$cocheDeJuanK->getMarca();
$cocheDeJuanK->getColor();
$bicicletaJulieta->getAnno();
$cocheDeLuis->anda(30);
$cocheDeLuis->getKmRecorridos();
$cocheDeJuanK->quemaRueda();
$cocheDeLuis->anda(40);
$cocheDeLuis->anda(220);
$bicicletaJulieta->anda(10);
$cocheDeLuis->quemaRueda();
$bicicletaJulieta->hacerCaballito();
$cocheDeJuanK->anda(60);
$cocheDeJuanK->anda(150);
$cocheDeJuanK->anda(90);
$bicicletaJulieta->anda(6);
echo "El coche de Luis ha recorrido " . $cocheDeLuis->getKmRecorridos() . "Km.<br>";
echo "El coche de Juan Carlos ha recorrido " . $cocheDeJuanK->getKmRecorridos() . "Km.<br>";
Example #3
0
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
include_once './Vehiculo.php';
include_once './Bicicleta.php';
include_once './Coche.php';
$bicicleta = new Bicicleta();
$coche = new Coche();
$bicicleta->anda(20);
echo "He recorrido con la bicicleta " . $bicicleta->getKmRecorridos() . " km.<br/>";
echo $bicicleta->hacerCaballito() . "<br/>";
$coche->anda(30);
echo "He recorrido con el coche " . $coche->getKmRecorridos() . " km.<br/>";
echo $coche->quemarRueda() . "<br/>";
?>
    </body>
</html>
Example #4
0
    echo " disabled>BICI CREADA</button>";
}
?>
    </form>
    <form action="ejers.php?carp=ejer04&ejer=ejer04" method="post" class="botonInline">
      <button class="waves-effect waves-light btn blue-grey darken-3" 
        type="submit" name="crearCoche" 
<?php 
if (!isset($_REQUEST['crearCoche'])) {
    if ($coche) {
        echo " disabled>COCHE CREADO</button>";
    } else {
        echo ">CREAR COCHE</button>";
    }
} else {
    $coche = new Coche();
    echo " disabled>COCHE CREADO</button>";
}
?>
    </form>
  </section>
  
  <section class="section">
<?php 
$accion = $_REQUEST['accion'];
if (isset($accion)) {
    switch ($accion) {
        case 'op1':
            if ($bici) {
                if (!$_REQUEST['kmBici']) {
                    ?>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
    <h2>2. Crea la clase Vehiculo , así como las clases Bicicleta y Coche como subclases de la primera.<br>
      Para la clase Vehiculo , crea los métodos de clase getVehiculosCreados() y getKmTotales() ; así como el
método de instancia getKmRecorridos() . <br>
Crea también algún método específico para cada una de las subclases.</h2>
  <?php 
include_once 'Vehiculo.php';
include_once 'Bicicleta.php';
include_once 'Coche.php';
$cocheDeLuis = new Coche("Saab", "93", "2540CKF");
$cocheDeJuanK = new Coche("Toyota", "Avensis", "4022GVV");
$bicidePedro = new Bicicleta("Monty", "road", "10");
$cocheDeLuis->recorre(30);
$cocheDeLuis->recorre(220);
$cocheDeJuanK->recorre(60);
$cocheDeJuanK->recorre(90);
$bicidePedro->recorre(2);
echo "<br>";
echo $bicidePedro->caballito();
echo "<br>";
echo "El coche de Luis ha recorrido " . $cocheDeLuis->getKilometraje() . "Km<br>";
echo "El coche de Juan Carlos ha recorrido " . $cocheDeJuanK->getKilometraje() . "Km<br>";
echo "La bici de Pedro ha recorrido " . $bicidePedro->getKilometraje() . "Km<br>";
echo "<br>";
echo "KILOMETRAJE TOTAL: " . Vehiculo::getKmTotales() . "Km<br>";
echo "NUMERO VEHICULOS CREADOS: " . Vehiculo::getVehiculosCreados() . "<br>";
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>POO1</title>
    </head>
    <body>
        <h1>Esto es una prueba</h1>
        <h1>Ahora lo estoy modificando desde la pág de GitHub</h1>
        <?php 
include 'vehiculos.php';
$mazda = new Coche();
$pegaso = new Camion();
echo 'El mazda tiene ' . $mazda->getRuedas() . ' ruedas<br>';
echo 'El pegaso tiene ' . $pegaso->getRuedas() . ' ruedas<br>';
echo 'El mazda tiene un motor de ' . $mazda->getMotor() . ' cc<br>';
?>
    </body>
</html>

Example #7
0
<?php

header('Content-Type: text/html; charset=UTF-8');
include "autoload.php";
// Para que incluya automáticamente todas las clases
// Instancia miCoche
$miCoche = new Coche();
echo nl2br("Intancia miCoche\n");
echo nl2br("{$miCoche->color}\n");
$miCoche->getModelo();
echo $miCoche->getTipo();
echo nl2br("\n");
$miCoche->encender();
echo nl2br("\n");
// Instancia otroCoche
$otroCoche = new Coche("Blanco", 2015, "Pick-up", 2, false);
echo nl2br("Intancia otroCoche\n");
echo nl2br("{$otroCoche->color}\n");
$otroCoche->getModelo();
echo $otroCoche->getTipo();
echo nl2br("\n");
$otroCoche->encender();
echo nl2br("\n");
// Instancia miFord (heredada)
$miFord = new Ford();
echo nl2br("Intancia miFord heredada\n");
echo nl2br("{$miFord->color}\n");
$miFord->getmodeloford();
echo $miFord->getTipoford();
$miFord->getLlavesford();
$miFord->encender();
 function arrancar()
 {
     parent::arrancar();
     echo 'Camión arrancado';
 }
• Ver kilometraje total

@author: Jesús Caballero Corpas
-->
<html>
  <head>
    <title>Capitulo 8 PHP POO - Ejercicio 4</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <div>
      <?php 
include_once 'Coche.php';
include_once 'Bicicleta.php';
$coche1 = new Coche("Peugeot", "206", "10");
echo "El " . $coche1->getMarca() . " " . $coche1->getModelo() . " " . $coche1->anda(20) . "<hr>";
echo $coche1->quemaRueda() . "<hr>";
echo $coche1->kilometros() . "<hr>";
echo $coche1 . "<hr>";
$bici1 = new Bicileta("Carreras", "5");
echo "La bicicleta " . $bici1->getModelo() . " " . $bici1->anda(20) . "<hr>";
echo $bici1->caballito() . "<hr>";
echo $bici1->kilometros() . "<hr>";
echo $bici1 . "<hr>";
echo "Vehiculos totales creados: " . Vehiculo::getVehiculosCreados() . "<hr>";
echo "Kilometros totales recorridos: " . Vehiculo::getKmTotales() . "<hr>";
?>
    </div>
  </body>
</html>
Example #10
0
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>

</head>

<body>

<?php 
include "vehiculos.php";
$mazda = new Coche();
$pegaso = new Camion();
echo "El Mazda tiene " . $mazda->get_ruedas() . " ruedas<br>";
echo "El Mazda tiene un motor de " . $mazda->get_motor() . " cc<br>";
?>

</body>
</html>
          •Anda con el coche
          •Quema rueda con el coche
          •Ver kilometraje de la bicicleta
          •Ver kilometraje del coche
          •Ver kilometraje total
      -->

      <h1>Vehículos</h1>

      <div id="contenido">

        <?php 
include_once "Bicicleta.php";
include_once "Coche.php";
$bici = new Bicicleta();
$carro = new Coche();
$bici->anda();
$bici->haceCaballito();
$carro->anda();
$carro->quemaRueda();
echo "<p>La bici ha recorrido " . $bici->getKmRecorridos() . "Km.</p>";
echo "<p>El coche ha recorrido " . $carro->getKmRecorridos() . "Km.</p>";
echo "<p>El kilometraje total ha sido de " . Vehiculo::getKmTotales() . "Km</p>";
echo "<p>Vehiculos creados: " . Vehiculo::getVehiculosCreados() . "</p>";
?>

      </div>

      <p id="author">Javier Roviralta Terrón</p>

    </div>
Example #12
0
File: index.php Project: nelbe/DWES
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
  </head>
  <body>
    <?php 
include_once 'Vehiculo.php';
include_once 'Bicicleta.php';
include_once 'Coche.php';
$biciUno = new Bicicleta("Ghost", "-", 32);
$biciDos = new Bicicleta("Cannondale", "lefty", "-");
$cocheUno = new Coche("Mercedes", "Benz", 190);
$cocheDos = new Coche("Peugeot", "206", 100);
$biciUno->anda(30);
$biciDos->anda(40);
$biciUno->anda(220);
$biciDos->anda(60);
$cocheUno->anda(200);
$cocheDos->anda(150);
$cocheUno->anda(300);
$cocheDos->anda(500);
echo $cocheUno . "<br><br>";
echo $cocheDos . "<br><br>";
echo $biciUno . "<br><br>";
echo $biciDos . "<br><br>";
echo "*************************BICICLETAS*****************************<br>";
echo "La biciUno ha recorrido " . $biciUno->getKilometraje() . "Km<br>";
echo $biciUno->caballito() . " BiciUno" . "<br>";
echo $biciUno->montaB() . " BiciUno" . "<br><br>";
echo "La biciDos ha recorrido " . $biciDos->getKilometraje() . "Km<br>";
Example #13
0
 function arrancar()
 {
     parent::arrancar();
     echo "Camión arrancado";
 }
        <title>Vehículos</title>
    </head>
    <body>
		<?php 
/*
 * EJERCICIOS DE POO CON PHP
 * RELACIÓN I
 * Ejercicio 4
 *
 * @author Luis José Sánchez
 * 
 */
include_once 'Bicicleta.php';
include_once 'Coche.php';
// crea una bicicleta con 21 marchas
$miBici = new Bicicleta("21");
// crea un coche con 1900cc de cilindrada
$miCoche = new Coche(1900);
$miBici->recorre(40);
$miCoche->recorre(200);
echo $miBici->hazCaballito() . "<br>";
echo $miCoche->quemaRueda() . "<br>";
$miBici->recorre(60);
echo "Mi bici ha recorrido " . $miBici->getKmRecorridos() . " Km<br>";
echo "Mi coche ha recorrido " . $miCoche->getKmRecorridos() . " Km<br>";
echo "Se han creado un total de " . Vehiculo::getVehiculosCreados() . " vehículos<br>";
echo "Todos los vehículos han hecho un total de " . Vehiculo::getKmTotales() . " Km<br>";
?>
    </body>
</html>
Example #15
0
• Ver kilometraje total
-->
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
   <!DOCTYPE html>
<?php 
include_once 'Vehiculo.php';
// no es necesario incluirla
include_once 'Bicicleta.php';
include_once 'Coche.php';
$miBici = new Bicicleta("Orbea", "Tech45", "21", "carreras");
$miCoche = new Coche("Ford", "Mondeo", "5", "gasoil");
echo "{$miBici}<hr>";
echo "{$miCoche}<hr>";
echo $miBici->anda(15);
echo $miBici->anda(35);
echo $miBici->haceCaballito();
echo $miCoche->anda(20);
echo $miCoche->anda(10);
echo $miCoche->quemaRueda();
echo "kilometros recorridos en mi bici: " . $miBici->getKmRecorridos() . "<br>";
echo "kilometros recorridos en mi coche: " . $miCoche->getKmRecorridos() . "<br>";
echo "kilometros totales recorridos: " . Vehiculo::getKmTotales() . "<br>";
?>
</body>

</html>
Example #16
0
 public function getModeloford()
 {
     return parent::getModelo();
 }