Last active
July 24, 2021 02:58
-
-
Save whitesoundcl/44674c2a692b8e810cbf100854896d50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Esto es una clase. | |
A partir de esta clase, vamos a instanciar varios objetos en la clase "Main.java" | |
Autor: WhitesoundCL | |
*/ | |
public class Vehiculo { | |
private String marca; | |
private String patente; | |
private String color; | |
private int litrosBencina; | |
// Este constructor nos permite crear un vehiculo sin ningún atributo. | |
public Vehiculo(){} | |
// Este constructor nos permite crear un vehiculo el cual va a contener inmediatamente | |
// todas sus variables asignadas. | |
public Vehiculo(String marca, String patente, String color, int litrosBencina | |
){ | |
this.marca = marca; | |
this.patente = patente; | |
this.color = color; | |
this.litrosBencina = litrosBencina; | |
} | |
// Cabe mencionar que aunque creemos un vehiculo sin atributos, siempre podemos | |
// Asignarselos más adelante en el código utilizando los getters y setters. | |
// (En la clase main hay un ejemplo de esto). | |
public String getMarca(){ | |
return this.marca; | |
} | |
public void setMarca(String marca) { | |
this.marca = marca; | |
} | |
public void setPatente(String pat){ | |
this.patente = pat; | |
} | |
public String getPatante(){ | |
return this.patente; | |
} | |
public void setColor(String color){ | |
this.color = color; | |
} | |
public String getColor(){ | |
return this.color; | |
} | |
public void setBencina(int bencina){ | |
this.litrosBencina = bencina; | |
} | |
public int getBencina(){ | |
return this.litrosBencina; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment