public class ScoreBoard {
private String team1;
private String team2;
private int score1;
private int score2;
private boolean active;
public ScoreBoard(String group1, String group2) {
team1 = group1;
team2 = group2;
score1 = 0;
score2 = 0;
active = true;
}
public void recordPlay(int points) {
if (points == 0) {
active = !active;
} else {
if (active) {
score1 += points;
} else {
score2 += points;
}
}
}
public String getScore() {
String result = score1 + "-" + score2 + "-";
if (active) {
result += team1;
} else {
result += team2;
}
return result;
}
}
public class WordChecker {
private ArrayList<String> wordList;
public boolean isWordChain() {
for (int index = 1; index < wordList.size(); index ++) {
if (!wordList.get(index).contains(wordList.get(index - 1))) {
return false;
}
}
return true;
}
public ArrayList<String> createList(String target) {
int len = target.length();
// private ArrayList<String> newList;
ArrayList<String> newList = new ArrayList<>();
for (int index = 0; index < wordList.size(); index ++) {
if (wordList.get(index).substring(0,len).equals(target)) {
newList.add(wordList.get(index).substring(0,len));
}
}
return newList;
}
}
public class Location {
private int theRow;
private int theCol;
public Location(int r, int c) {
theRow = r;
theCol = c;
}
public int getRow() {
return theRow;
}
public int getCol() {
return theCol;
}
}
public class GridPath {
private int[][] grid;
public Location getNextLoc(int row, int col) {
if (row == grid.length - 1) {
return Location(row , col + 1);
} else if (col == grid[0].length - 1) {
return Location(row + 1, col);
} else {
if (grid[row + 1][col] > grid[row][col + 1]) {
return Location(row, col + 1);
} else {
return Location(row + 1, col);
}
}
}
public int sumPath(int row, int col) {
int sum = 0;
while ((row != grid.length - 1) && (col != grid[0].length - 1)) {
sum += grid[row][col];
getNextLoc(row, col);
row = getRow();
col = getCol();
}
// int sum = 0;
// int currentRow = row;
// int currentCol = col;
// while ((currentRow != grid.length - 1) && (currentCol != grid[0].length - 1)) {
// sum += grid[row][col];
// Location nextLoc = getNextLoc(row, col);
// currentRow = nextLoc.getRow();
// currentCol = nextLoc.getCol();
// }
return sum;
}
}