Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1.  
  2. public class vehiculo {
  3.    
  4.     protected estado estadoVehiculo;
  5.     protected int velocidadActual;
  6.     protected int combustibleActual;
  7.    
  8.     public vehiculo(int combustible){
  9.         this.combustibleActual=combustible;
  10.         velocidadActual = 0;
  11.         estadoVehiculo=new estadoParado(this);
  12.     }
  13.  
  14.     public estado getEstadoVehiculo() {
  15.         return estadoVehiculo;
  16.     }
  17.  
  18.     public void setEstadoVehiculo(estado estadoVehiculo) {
  19.         this.estadoVehiculo = estadoVehiculo;
  20.     }
  21.  
  22.     public int getVelocidadActual() {
  23.         return velocidadActual;
  24.     }
  25.  
  26.     public void setVelocidadActual(int velocidadActual) {
  27.         this.velocidadActual = velocidadActual;
  28.     }
  29.  
  30.     public int getCombustibleActual() {
  31.         return combustibleActual;
  32.     }
  33.  
  34.     public void setCombustibleActual(int combustibleActual) {
  35.         this.combustibleActual = combustibleActual;
  36.     }
  37.    
  38.     public void modificarVelocidad(int nuevaVelocidad){
  39.         this.velocidadActual=this.velocidadActual+nuevaVelocidad;
  40.     }
  41.    
  42.     public void modificarCombustible(int nuevoCombustible){
  43.         this.combustibleActual=this.combustibleActual+nuevoCombustible;
  44.     }
  45.    
  46.     public void Acelerar()
  47.     {
  48.         estadoVehiculo.Acelerar();
  49.         System.out.println("Velocidad actual: " + velocidadActual + ". Combustible restante: " + combustibleActual);
  50.     }
  51.  
  52.     public void Frenar()
  53.     {
  54.         estadoVehiculo.Frenar();
  55.     }
  56.  
  57.     public void Contacto()
  58.     {
  59.         estadoVehiculo.Contacto();
  60.     }
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement