Created
May 21, 2020 23:44
-
-
Save parzibyte/bc65a6c6325886f9aa261b0661a51014 to your computer and use it in GitHub Desktop.
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
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