Skip to content

Commit

Permalink
Fix MultiIndex class
Browse files Browse the repository at this point in the history
  • Loading branch information
seox123 committed Oct 23, 2022
1 parent 296c92a commit 02ef48d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/main/java/seedu/waddle/commons/core/index/MultiIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ public void removeIndex(int pos) {
}
}

public Index getIndex(int pos) {
if (!isValidPos(pos)) {
throw new IndexOutOfBoundsException();
}
return indices.get(pos - 1);
}

public Index getDayIndex() {
if (this.indices.size() == 1) {
return null;
Expand All @@ -60,7 +53,12 @@ public Index getTaskIndex() {
return getIndex(2);
}


private Index getIndex(int pos) {
if (!isValidPos(pos)) {
throw new IndexOutOfBoundsException();
}
return indices.get(pos - 1);
}

private boolean isValidPos(int pos) {
if (pos < 1 || pos >= indices.size()) {
Expand All @@ -73,7 +71,7 @@ private boolean isValidPos(int pos) {
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < indices.size(); i++) {
sb.append(indices.get(i));
sb.append(indices.get(i).getOneBased());
if (i != indices.size() - 1) {
sb.append('.');
}
Expand Down

0 comments on commit 02ef48d

Please sign in to comment.