-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortableBeerList.java
More file actions
82 lines (58 loc) · 1.4 KB
/
SortableBeerList.java
File metadata and controls
82 lines (58 loc) · 1.4 KB
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
/**
* SortableBeerList.java
* Copyright (C) Caliana Fortin 2018
*/
package edu.ics211.h05;
import edu.ics211.h02.Beer;
import edu.ics211.h05.SortableList.IList211;
import java.util.Comparator;
/**
* SortableBeerList.
*
* @author Caliana Fortin
*
*/
public class SortableBeerList implements IList211<Beer> {
private SortableList<Beer> list;
Comparator<Beer> compare;
/**
* Creates a new SortableBeerList.
*
* @param compare compares the beers
*/
public SortableBeerList(Comparator<Beer> compare) {
list = new SortableList<Beer>();
}
@Override
public Beer get(int index) {
return this.list.get(index);
}
@Override
public Beer set(int index, Beer element) {
return this.list.set(index, element);
// I know it has to sort after adding the element here
// keep getting a null pointer exception when trying to sort
}
@Override
public int indexOf(Object obj) {
return this.list.indexOf(obj);
}
@Override
public int size() {
return this.list.size();
}
@Override
public boolean add(Beer e) {
return this.list.add(e);
// I know it has to sort after adding the element here
}
@Override
public void add(int index, Beer element) {
this.list.add(index, element);
// I know it has to sort after adding the element here
}
@Override
public Beer remove(int index) {
return this.list.remove(index);
}
}