Skip to content

Commit

Permalink
Refactor initialization of max step.
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Jun 8, 2015
1 parent 14d7692 commit 37b1caf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
9 changes: 5 additions & 4 deletions app/src/main/java/net/exkazuu/mimicdance/Lessons.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ public class Lessons {
"くりかえし3\n左腕を上げる\n左腕を下げる\nここまで\nくりかえし3\n右腕を上げる\n右腕を下げる\nここまで",
"右腕を上げる\nもしも黄色\n右腕を下げる\nもしくは\n左腕を上げる\nもしおわり",
"くりかえし3\nもしも黄色\n右腕を上げる\n右腕を下げる\nもしくは\n左腕を上げる\n左腕を下げる\nもしおわり\nここまで",
"くりかえし2\nもしも黄色\n左腕を上げる\n左腕を下げる\nもしくは\n右腕を上げる\n右腕を下げる\nもしおわり\nここまで",};
//"くりかえし2\nもしも黄色\n左腕を上げる\n左腕を下げる\nもしくは\n右腕を上げる\n右腕を下げる\nもしおわり\nここまで",
};

private static int[] limitations = {10, 12, 10, 8, 10, 10, 10}; // hard
private static int[] maxSteps = {10, 12, 10, 8, 10, 10};

public static String getCoccoCode(int lessonNumber) {
return coccoCodes[lessonNumber - 1];
}

public static int getLimitation(int lessonNumber) {
return limitations[lessonNumber - 1];
public static int getMaxStep(int lessonNumber) {
return maxSteps[lessonNumber - 1];
}

public static int getLessonCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onCreate(Bundle savedInstanceState) {
initializeNumberIcons(cellTexts, cellIcons);

ImageView[] steps = initializeStepNumbers();
initializeMaximumStep(cellIcons, steps);
initializeMaximumStep(cellIcons, steps, Lessons.getMaxStep(lessonNumber));
}

private String[][] initializeCellTexts(String piyoCode) {
Expand Down Expand Up @@ -105,19 +105,7 @@ private void initializeNumberIcons(String[][] cellTexts, ImageView[][] cellIcons
}
}

private void initializeMaximumStep(ImageView[][] cells, ImageView[] step) {
if (lessonNumber == 2) {
setMaximumStep(cells, step, 12);
} else if (lessonNumber == 4) {
setMaximumStep(cells, step, 8);
} else if (lessonNumber == 7) {
setMaximumStep(cells, step, 12);
} else {
setMaximumStep(cells, step, 10);
}
}

private void setMaximumStep(ImageView[][] cells, ImageView[] step, int maxStep) {
private void initializeMaximumStep(ImageView[][] cells, ImageView[] step, int maxStep) {
for (int row = 0; row < maxStep; row++) {
for (int column = 0; column < cells[0].length; column++) {
cells[row][column].setVisibility(View.VISIBLE);
Expand Down

0 comments on commit 37b1caf

Please sign in to comment.