-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLager.~ava
96 lines (85 loc) · 2.38 KB
/
Lager.~ava
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
*
* Description
*
* @version 1.0 from 5/14/2020
* @author
*/
public class Lager {
// start attributes
private List<Artikel> myitems;
private int artikelnummercounter = 0;
// end attributes
public Lager() {
this.myitems = new List<Artikel>();
}
// start methods
public List<Artikel> getMyitems() {
return myitems;
}
public void setMyitems(List<Artikel> myitemsNew) {
myitems = myitemsNew;
}
public List<Artikel> searchitem(String pname){
this.myitems.toFirst();
List<Artikel> temp = new List<Artikel>();
while (this.myitems.hasAccess()) {
if (this.myitems.getContent().getName().toLowerCase().equals(pname.toLowerCase())) {
temp.append(myitems.getContent());
} // end of if
this.myitems.next();
} // end of while
return temp;
}
public Artikel searchitemtbynumber(int number){
myitems.toFirst();
while (this.myitems.hasAccess()) {
if (this.myitems.getContent().getArtikelnummer()==number) {
return myitems.getContent();
} // end of if
this.myitems.next();
} // end of while
return null;
}
public void additem(String pname, int ppreis, String Beschreibung, String Hersteller) {
Artikel temp = new Artikel(pname,artikelnummercounter,ppreis,Beschreibung,Hersteller);
artikelnummercounter++;
this.myitems.append(temp);
}
public void sort(){
List<Artikel> temp = new List<Artikel>();
while (!myitems.isEmpty()) {
myitems.toFirst();
Artikel max = myitems.getContent();
while (myitems.hasAccess()) {
if (myitems.getContent().getverkaufszahl()>max.getverkaufszahl()) {
max = myitems.getContent();
} // end of if
myitems.next();
} // end of while
temp.append(max);
myitems.toFirst();
while (myitems.hasAccess()) {
if (myitems.getContent()==max) {
myitems.remove();
} else {
myitems.next();
} // end of if-else
} // end of while
} // end of while
this.myitems.concat(temp);
}
public List<Artikel> nmostpopular(int n){
List<Artikel> temp = new List<Artikel>();
myitems.toFirst();
this.sort();
int k = 0;
while (myitems.hasAccess()&&k<n) {
temp.append(myitems.getContent());
myitems.next();
k++;
} // end of while
return temp;
}
// end methods
} // end of Lager