Skip to content

Commit

Permalink
Merge pull request #881 from daniel-gf05/master
Browse files Browse the repository at this point in the history
cambio3
  • Loading branch information
kant003 authored Oct 25, 2024
2 parents 4c81d8c + 0ed4b0a commit 0a82857
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
66 changes: 66 additions & 0 deletions danielGayoso3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import java.util.Scanner;

public class Propuesto11 {

private double chocos = 0;
private double papas = 0;
private int clientes = 0;

public Propuesto11(double chocos, double papas) {
this.chocos = chocos;
this.papas = papas;
}

public Propuesto11() {
this.chocos = 0;
this.papas = 0;
}

public double getChocos() {
return chocos;
}

public void setChocos(double chocos) {
this.chocos = chocos;
}

public double getPapas() {
return papas;
}

public void setPapas(double papas) {
this.papas = papas;
}

public int pedirClientes() {
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el número de clientes: ");
this.clientes = sc.nextInt();
return clientes;
}

public void pedirProductos() {
Scanner sc = new Scanner(System.in);
System.out.println("Introduce la cantidad de papas: ");
this.papas = sc.nextDouble();
System.out.println("Introduce la cantidad de chocos: ");
this.chocos = sc.nextDouble();
}

public double personasAlimentar() {
boolean a = true;
do {
if (papas >= 1 && chocos >= 0.5) {
this.clientes += 3;
this.papas -= 1;
this.chocos -= 0.5;
} else if (papas < 1 || chocos < 0.5) {
a = false;
} else {
System.out.println("Error");
a = false;
}
} while (a == true);
return this.clientes;
}
}
57 changes: 57 additions & 0 deletions danielGayoso4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package Tema2;

public class coche {

private int velocidad;
//Constructor
public coche() {
velocidad = 0;
}

public coche(int velocidad){
super();
this.velocidad = velocidad;
}

public int getVelocidad() {
return velocidad;
}

public void setVelocidad(int velocidad) {
this.velocidad = velocidad;
}
//limite 120
public void acelera(int chop){

if (velocidad+chop>120) {
velocidad = 120;
}
else{
velocidad+=chop;
}
}

public void frena(int cant){

if (velocidad-cant<0) {
velocidad=0;
}
else{
velocidad-=cant;
}
}

public static void main(String[] args) {

}

@Override
public String toString() {
return "Coche [velocidad=" + velocidad + "]";
}





}
8 changes: 8 additions & 0 deletions test_danielGayoso3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class test_propuesto11 {
public static void main(String[] args) {
Propuesto11 rest1 = new Propuesto11();
rest1.pedirClientes();
rest1.pedirProductos();
rest1.personasAlimentar();
}
}
30 changes: 30 additions & 0 deletions test_danielGayoso4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Tema2;

import java.util.Scanner;

public class coche_test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
coche renault = new coche();
System.out.println("Introduce la velocidad del vehículo");
int vel = sc.nextInt();
System.out.println("Cuanto acelera el vehículo?");
int acelera = sc.nextInt();
System.out.println("Cuanto frena el vehículo?");
int frena = sc.nextInt();
renault.setVelocidad(vel);
System.out.println(renault.toString());
renault.acelera(acelera);
System.out.println(renault.toString());
renault.frena(frena);
System.out.println(renault.toString());

coche merchi = new coche();
System.out.println("Introduce la velocidad de merchi: ");
int vm = sc.nextInt();
merchi.setVelocidad(vm);
System.out.println(merchi.toString());
int potito=merchi.getVelocidad();
System.out.println(potito);
}
}

0 comments on commit 0a82857

Please sign in to comment.