-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModeloArrayList.java
79 lines (61 loc) · 1.6 KB
/
ModeloArrayList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package CRUD;
import java.util.Scanner;
/**
* Implementa la parte de Modelo de Datow
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.ArrayList;
public class ModeloArrayList extends ModeloAbs
{
private ArrayList <Producto> lista;
Scanner sc=new Scanner(System.in);
public ModeloArrayList()
{
lista=new ArrayList <Producto>();
}
// Implementar los metodos abstractos de ModeloAbs
public boolean insertarProducto ( Producto p){
boolean retorno= false;
if(p!=null) {
lista.add(p);
retorno = true;
}
return retorno;
}
public boolean borrarProducto ( int codigo ){
boolean retorno=false;
if(buscarProducto(codigo)!=null) {
lista.remove(buscarProducto(codigo));
retorno=true;
}
return retorno;
}
public Producto buscarProducto ( int codigo) {
Producto r= null;
for(int i=0;i<lista.size();i++) {
if(lista.get(i).getCodigo()==codigo) {
r=lista.get(i);
break;
}
}
return r;
}
public void listarProductos (){
for(int i=0;i<lista.size();i++) {
System.out.println(lista.get(i));
}
}
public void listarPocoStock() {
for (int i=0;i<lista.size();i++) {
if(lista.get(i).getStock_min()>=lista.get(i).getStock()) {
System.out.println(lista.get(i));
}
}
}
public boolean modificarProducto (Producto nuevo){
boolean resultado=false;
return resultado;
}
}