-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #780 from gabrimdez/master
prueba de java
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
public class prueba2 { | ||
|
||
// atributos | ||
|
||
private double km; // kilometros recorridos | ||
private double litros; // litros consumidos | ||
private double vmed; // velocidad media | ||
private double pgas; // precio gasolina | ||
|
||
// constructor | ||
|
||
public prueba2(double km, double litros, double vmed, double pgas) { | ||
super(); | ||
this.km = km; | ||
this.litros = litros; | ||
this.vmed = vmed; | ||
this.pgas = pgas; | ||
|
||
// getters y setters | ||
} | ||
|
||
public double getKm() { | ||
return km; | ||
} | ||
|
||
public void setKm(double km) { | ||
this.km = km; | ||
} | ||
|
||
public double getLitros() { | ||
return litros; | ||
} | ||
|
||
public void setLitros(double litros) { | ||
this.litros = litros; | ||
} | ||
|
||
public double getVmed() { | ||
return vmed; | ||
} | ||
|
||
public void setVmed(double vmed) { | ||
this.vmed = vmed; | ||
} | ||
|
||
public double getPgas() { | ||
return pgas; | ||
} | ||
|
||
public void setPgas(double pgas) { | ||
this.pgas = pgas; | ||
} | ||
|
||
// metodos propios de la clase | ||
|
||
public double dimeTiempo() { | ||
return km / vmed; | ||
} | ||
|
||
public double consumoMedio() { // De 100km | ||
return litros / km * 100; | ||
} | ||
|
||
public double consumoEuros() { | ||
return km * pgas; | ||
|
||
/* | ||
* double aux = this.consumoMedio(); return aux * pgas; | ||
*/ | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "prueba2 [km=" + km + ", litros=" + litros + ", vmed=" + vmed + ", pgas=" + pgas + "]"; | ||
} | ||
|
||
} |