forked from MrBly/WalnutiQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formatter.java
34 lines (29 loc) · 1 KB
/
Formatter.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
package model.util;
import model.MARK_II.ColumnPosition;
import java.util.Set;
/**
* @author Quinn Liu ([email protected])
* @version August 1, 2014
*/
public class Formatter {
/**
* @return Return the list of active column positions in the following
* format: ((0, 0), (1, 1), (2, 2), (2,0))
*/
public static String format(Set<ColumnPosition> activeColumnPositions) {
String listOfActiveColumns = "(";
int numberOfActiveColumns = activeColumnPositions.size();
for (ColumnPosition columnPosition : activeColumnPositions) {
listOfActiveColumns += "(" + columnPosition.getRow() + ", " +
columnPosition.getColumn() + ")";
--numberOfActiveColumns;
if (numberOfActiveColumns == 0) {
// this is the last active column so don't print ", "
} else {
listOfActiveColumns += ", ";
}
}
listOfActiveColumns += ")";
return listOfActiveColumns;
}
}