Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 21, 2020 23:44
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/bc65a6c6325886f9aa261b0661a51014 to your computer and use it in GitHub Desktop.
Save parzibyte/bc65a6c6325886f9aa261b0661a51014 to your computer and use it in GitHub Desktop.
public static void agregarProducto(ArrayList<Producto> productos) {
productos.add(solicitarProducto());
}
public static void cambiarCantidad(ArrayList<Producto> productos) {
int indice = solicitarIndice();
Producto p = productos.get(indice);
Scanner sc = new Scanner(System.in);
System.out.println("Nueva cantidad: ");
double nuevaCantidad = sc.nextDouble();
p.setCantidad(nuevaCantidad);
productos.set(indice, p);
}
public static void quitarProducto(ArrayList<Producto> productos) {
int indice = solicitarIndice();
if (indice < productos.size()) {
productos.remove(indice);
} else {
System.out.println("Número no válido");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment