-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 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,25 @@ | ||
package burger; | ||
|
||
/** | ||
* 1. Clientes recogen productos de 1 en 1 | ||
* 2. Clientes recogen todo el pedido de golpe | ||
* 3. Se incorporan las patatas como segundo producto | ||
* 4. La bandeja de salida tiene un tamaño limitado | ||
*/ | ||
|
||
public class Main { | ||
|
||
public static final String CLEAR = "\n".repeat(50); | ||
|
||
public static void main(String[] args) { | ||
|
||
Pedido pedido = Pedido.pedidoAleatorio(); | ||
|
||
System.out.println(pedido); | ||
|
||
pedido.hamburguesasRecogidas++; | ||
System.out.println(CLEAR); | ||
System.out.println(pedido); | ||
|
||
} | ||
} |
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,37 @@ | ||
package burger; | ||
|
||
public class Pedido { | ||
public static final String HAMBURGUESA = "🍔"; | ||
public static final String PATATAS = "🍟"; | ||
public static final int MAX_ITEMS = 4; | ||
|
||
public int hamburguesas, hamburguesasRecogidas; | ||
public int patatas, patatasRecogidas; | ||
public long creacion; | ||
|
||
public static Pedido pedidoAleatorio() { | ||
int nHamburguesas = (int) (1 + Math.random()*MAX_ITEMS); | ||
int nPatatas = (int) (Math.random()*MAX_ITEMS); | ||
return new Pedido(nHamburguesas, nPatatas); | ||
} | ||
|
||
public Pedido(int hamburguesas, int patatas) { | ||
this.hamburguesas = hamburguesas; | ||
this.patatas = patatas; | ||
this.creacion = System.currentTimeMillis(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String res = "----------------\n"; | ||
res += "Creado hace %3s segs\n".formatted((System.currentTimeMillis()-creacion)/1000); | ||
res += "----------------\n"; | ||
res += "Hamburguesas: "+ HAMBURGUESA.repeat(hamburguesas) + "\n"; | ||
res += "Recibidas: "+ HAMBURGUESA.repeat(hamburguesasRecogidas) + "\n"; | ||
res += "----------------\n"; | ||
res += "Patatas: "+ PATATAS.repeat(patatas) + "\n"; | ||
res += "Recibidas: "+ PATATAS.repeat(patatasRecogidas) + "\n"; | ||
res += "----------------\n"; | ||
return res; | ||
} | ||
} |