Skip to content

Commit

Permalink
Merge pull request #780 from gabrimdez/master
Browse files Browse the repository at this point in the history
prueba de java
  • Loading branch information
kant003 authored Oct 22, 2024
2 parents f9c20f1 + 92cae3a commit 65056da
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions prueba2.java
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 + "]";
}

}

0 comments on commit 65056da

Please sign in to comment.