Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 21, 2020 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/503a4bfa3f95b8829452c173f2269311 to your computer and use it in GitHub Desktop.
Save parzibyte/503a4bfa3f95b8829452c173f2269311 to your computer and use it in GitHub Desktop.
public static void mostrarTicket(ArrayList<Producto> productos) {
System.out.println("-".repeat(85));
System.out.printf("|%-20s|%-20s|%-20s|%-20s|\n", "Descripción", "Precio", "Cantidad", "Subtotal");
System.out.println("-".repeat(85));
double total = 0;
for (Producto p : productos) {
System.out.printf("|%-20s|%-20f|%-20f|%-20f|\n", p.getDescripcion(), p.getPrecio(), p.getCantidad(), p.getSubtotal());
total += p.getSubtotal();
}
System.out.println("-".repeat(85));
System.out.printf("|%83s|\n", "Total: " + String.valueOf(total));
System.out.println(" **Gracias por su compra**");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment