-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCloset.java
More file actions
32 lines (29 loc) · 825 Bytes
/
Copy pathCloset.java
File metadata and controls
32 lines (29 loc) · 825 Bytes
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
public class Closet {
private Shirt[] shirts;
public Closet(Shirt[] shirts){
this.shirts = shirts;
}
public Shirt[] getShirts() {
return shirts;
}
public Shirt[] getShirtsBySize(int size){
int emptyslot = 0;
for (int i = 0; i < shirts.length; i++) {
if (shirts[i].getSize()==size) {
emptyslot++;
}
}
Shirt[] sizeMatch = new Shirt[emptyslot];
emptyslot = 0;
for (int i = 0; i < shirts.length; i++) {
if (shirts[i].getSize()==size) {
sizeMatch[emptyslot] = shirts[i];
emptyslot++;
}
}
return sizeMatch;
}
public void addShirtToArrayOfCloset(Shirt shirt){
shirts = Util.addShirtToArray(shirt,shirts);
}
}