Skip to content

Commit

Permalink
Improved dakuten/handakuten separation from normal characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikamander2 committed Jan 16, 2015
1 parent 9350f84 commit 79d74e6
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 88 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pikamander2.japanesequiz"
android:versionCode="5"
android:versionName="1.0.4" >
android:versionCode="6"
android:versionName="1.0.5" >

<uses-sdk
android:minSdkVersion="14"
Expand Down
Binary file added Screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<string name="buttonKatakana">Katakana</string>
<string name="buttonKanji">Kanji</string>
<string name="buttonMixture">Mixture</string>
<string name="VersionNumber">Version 1.0.4</string>
<string name="VersionNumber">Version 1.0.5</string>
<string name="buttonFlip">Flip questions</string>

</resources>
2 changes: 1 addition & 1 deletion src/com/pikamander2/japanesequiz/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ public boolean onOptionsItemSelected(MenuItem item)

return super.onOptionsItemSelected(item);
}
}
}
170 changes: 100 additions & 70 deletions src/com/pikamander2/japanesequiz/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,110 +6,140 @@
import java.util.Random;

public class Question
{
{
private Random random = new Random();

private int currentAnswer;

private ArrayList<String[]> listToUse;

private int listId;

private static String[][] tempHiraganaList = {{"あ", "a"},{"い", "i"},{"う", "u"},{"え", "e"},{"お", "o"},
{"か", "ka"},{"き", "ki"},{"く", "ku"},{"け", "ke"},{"こ", "ko"},
{"さ", "sa"},{"し", "shi"},{"す", "su"},{"せ", "se"},{"そ", "so"},
{"た", "ta"},{"ち", "chi"},{"つ", "tsu"},{"て", "te"},{"と", "to"},
{"な", "na"},{"に", "ni"},{"ぬ", "nu"},{"ね", "ne"},{"の", "no"},
{"は", "ha"},{"ひ", "hi"},{"ふ", "fu"},{"へ", "he"},{"ほ", "ho"},
{"ま", "ma"},{"み", "mi"},{"む", "mu"},{"め", "me"},{"も", "mo"},
{"や", "ya"},{"ゆ", "yu"},{"よ", "yo"},
{"ら", "ra"},{"り", "ri"},{"る", "ru"},{"れ", "re"},{"ろ", "ro"},
{"わ", "wa"},{"を", "wo"},
{"ん", "n"},
{"が", "ga"},{"ぎ", "gi"},{"ぐ", "gu"},{"げ", "ge"},{"ご", "go"},
{"ざ", "za"},{"じ", "ji"},{"ず", "zu"},{"ぜ", "ze"},{"ぞ", "zo"},
{"だ", "da"},{"ぢ", "ji"},{"づ", "zu"},{"で", "de"},{"ど", "do"},
{"ば", "ba"},{"び", "bi"},{"ぶ", "bu"},{"べ", "be"},{"ぼ", "bo"},
{"ぱ", "pa"},{"ぴ", "pi"},{"ぷ", "pu"},{"ぺ", "pe"},{"ぽ", "po"}
};

private static ArrayList<String[]> hiraganaList = new ArrayList<String[]>(Arrays.asList(tempHiraganaList));

private static String[][] tempKatakanaList = {{"ア", "a"},{"イ", "i"},{"ウ", "u"},{"エ", "e"},{"オ", "o"},
{"カ", "ka"},{"キ", "ki"},{"ク", "ku"},{"ケ", "ke"},{"コ", "ko"},
{"サ", "sa"},{"シ", "shi"},{"ス", "su"},{"セ", "se"},{"ソ", "so"},
{"タ", "ta"},{"チ", "chi"},{"ツ", "tsu"},{"テ", "te"},{"ト", "to"},
{"ナ", "na"},{"ニ", "ni"},{"ヌ", "nu"},{"ネ", "ne"},{"ノ", "no"},
{"ハ", "ha"},{"ヒ", "hi"},{"フ", "fu"},{"ヘ", "he"},{"ホ", "ho"},
{"マ", "ma"},{"ミ", "mi"},{"ム", "mu"},{"メ", "me"},{"モ", "mo"},
{"ヤ", "ya"},{"ユ", "yu"},{"ヨ", "yo"},
{"ラ", "ra"},{"リ", "ri"},{"ル", "ru"},{"レ", "re"},{"ロ", "ro"},
{"ワ", "wa"},{"ヲ", "wo"},
{"ン", "n"},
{"ガ", "ga"},{"ギ", "gi"},{"グ", "gu"},{"ゲ", "ge"},{"ゴ", "go"},
{"ザ", "za"},{"ジ", "ji"},{"ズ", "zu"},{"ゼ", "ze"},{"ゾ", "zo"},
{"ダ", "da"},{"ヂ", "ji"},{"ヅ", "zu"},{"デ", "de"},{"ド", "do"},
{"バ", "ba"},{"ビ", "bi"},{"ブ", "bu"},{"ベ", "be"},{"ボ", "bo"},
{"パ", "pa"},{"ピ", "pi"},{"プ", "pu"},{"ペ", "pe"},{"ポ", "po"}
};

private static ArrayList<String[]> katakanaList = new ArrayList<String[]>(Arrays.asList(tempKatakanaList));

private boolean romajiFirst = true;

private static ArrayList<String[]> plainHiragana = new ArrayList<String[]>(Arrays.asList(new String[][]{{"あ", "a"},{"い", "i"},{"う", "u"},{"え", "e"},{"お", "o"},
{"か", "ka"},{"き", "ki"},{"く", "ku"},{"け", "ke"},{"こ", "ko"},
{"さ", "sa"},{"し", "shi"},{"す", "su"},{"せ", "se"},{"そ", "so"},
{"た", "ta"},{"ち", "chi"},{"つ", "tsu"},{"て", "te"},{"と", "to"},
{"な", "na"},{"に", "ni"},{"ぬ", "nu"},{"ね", "ne"},{"の", "no"},
{"は", "ha"},{"ひ", "hi"},{"ふ", "fu"},{"へ", "he"},{"ほ", "ho"},
{"ま", "ma"},{"み", "mi"},{"む", "mu"},{"め", "me"},{"も", "mo"},
{"や", "ya"},{"ゆ", "yu"},{"よ", "yo"},
{"ら", "ra"},{"り", "ri"},{"る", "ru"},{"れ", "re"},{"ろ", "ro"},
{"わ", "wa"},{"を", "wo"},
{"ん", "n"}}));

private static ArrayList<String[]> dakutenHiragana = new ArrayList<String[]>(Arrays.asList(new String[][]{
{"が", "ga"},{"ぎ", "gi"},{"ぐ", "gu"},{"げ", "ge"},{"ご", "go"},
{"ざ", "za"},{"じ", "ji"},{"ず", "zu"},{"ぜ", "ze"},{"ぞ", "zo"},
{"だ", "da"},{"ぢ", "ji"},{"づ", "zu"},{"で", "de"},{"ど", "do"},
{"ば", "ba"},{"び", "bi"},{"ぶ", "bu"},{"べ", "be"},{"ぼ", "bo"},
{"ぱ", "pa"},{"ぴ", "pi"},{"ぷ", "pu"},{"ぺ", "pe"},{"ぽ", "po"}
}));

private static ArrayList<String[]> plainKatakana = new ArrayList<String[]>(Arrays.asList(new String[][]{{"ア", "a"},{"イ", "i"},{"ウ", "u"},{"エ", "e"},{"オ", "o"},
{"カ", "ka"},{"キ", "ki"},{"ク", "ku"},{"ケ", "ke"},{"コ", "ko"},
{"サ", "sa"},{"シ", "shi"},{"ス", "su"},{"セ", "se"},{"ソ", "so"},
{"タ", "ta"},{"チ", "chi"},{"ツ", "tsu"},{"テ", "te"},{"ト", "to"},
{"ナ", "na"},{"ニ", "ni"},{"ヌ", "nu"},{"ネ", "ne"},{"ノ", "no"},
{"ハ", "ha"},{"ヒ", "hi"},{"フ", "fu"},{"ヘ", "he"},{"ホ", "ho"},
{"マ", "ma"},{"ミ", "mi"},{"ム", "mu"},{"メ", "me"},{"モ", "mo"},
{"ヤ", "ya"},{"ユ", "yu"},{"ヨ", "yo"},
{"ラ", "ra"},{"リ", "ri"},{"ル", "ru"},{"レ", "re"},{"ロ", "ro"},
{"ワ", "wa"},{"ヲ", "wo"},
{"ン", "n"}
}));

private static ArrayList<String[]> dakutenKatakana = new ArrayList<String[]>(Arrays.asList(new String[][]{
{"ガ", "ga"},{"ギ", "gi"},{"グ", "gu"},{"ゲ", "ge"},{"ゴ", "go"},
{"ザ", "za"},{"ジ", "ji"},{"ズ", "zu"},{"ゼ", "ze"},{"ゾ", "zo"},
{"ダ", "da"},{"ヂ", "ji"},{"ヅ", "zu"},{"デ", "de"},{"ド", "do"},
{"バ", "ba"},{"ビ", "bi"},{"ブ", "bu"},{"ベ", "be"},{"ボ", "bo"},
{"パ", "pa"},{"ピ", "pi"},{"プ", "pu"},{"ペ", "pe"},{"ポ", "po"}
}));

public Question(int tempListId)
{
listId = tempListId;
setList(tempListId);
}

public void shuffleQuestions()
public void switchRomajiFirst()
{
if (listId == 4)
{
setList(4);
}
romajiFirst = !romajiFirst;
}

public void shuffleQuestions()
{
setList(listId);

Collections.shuffle(listToUse);
}

public void setList(int tempListId)
{
int randNum;

if (tempListId == 4)
{
tempListId = random.nextInt(2) + 1;
}

switch(tempListId)
{
case 1:
listToUse = hiraganaList;
case 1: //Hiragana
randNum = random.nextInt(plainHiragana.size() + dakutenHiragana.size());

if (randNum < plainHiragana.size())
{
listToUse = plainHiragana;
}

else
{
listToUse = dakutenHiragana;
}

break;
case 2:
listToUse = katakanaList;
case 2: //Katakana
randNum = random.nextInt(plainKatakana.size() + dakutenKatakana.size());

if (randNum < plainKatakana.size())
{
listToUse = plainKatakana;
}

else
{
listToUse = dakutenKatakana;
}

break;
}
}

public String getAnswer(int charID, boolean romajiFirst)
public String getAnswer(int charID)
{
if (romajiFirst)
{
return listToUse.get(charID)[0];
}
return listToUse.get(charID)[romajiFirst ? 0 : 1];
}

else
{
return listToUse.get(charID)[1];
}
public void setCurrentAnswer(int answer)
{
this.currentAnswer = answer;
}

public String getQuestion(int charID, boolean romajiFirst)
public String getCurrentAnswer()
{
if (romajiFirst)
{
return listToUse.get(charID)[1];
}
return listToUse.get(currentAnswer)[romajiFirst ? 0 : 1];
}

else
{
return listToUse.get(charID)[0];
}
public String getQuestion(int charID)
{
return listToUse.get(charID)[romajiFirst ? 1 : 0];
}

public ArrayList<String[]> getUsedList()
{
return listToUse;
}
}
}
15 changes: 8 additions & 7 deletions src/com/pikamander2/japanesequiz/QuestionAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public QuestionAdapter(Context c, Question q)
question = q;
}

public void changeAnswers(boolean romajiFirst)
public void changeAnswers()
{
buttons.get(0).setText(question.getAnswer(0, romajiFirst));
buttons.get(1).setText(question.getAnswer(1, romajiFirst));
buttons.get(2).setText(question.getAnswer(2, romajiFirst));
buttons.get(3).setText(question.getAnswer(3, romajiFirst));
buttons.get(0).setText(question.getAnswer(0));
buttons.get(1).setText(question.getAnswer(1));
buttons.get(2).setText(question.getAnswer(2));
buttons.get(3).setText(question.getAnswer(3));
}

public void makeButtons()
{
for (int i = 0; i < 4; i++)
Expand All @@ -45,9 +45,10 @@ public void makeButtons()
newButton.setOnClickListener(mContext.answerOnClick);
buttons.add(newButton);
newButton.setTextSize(TypedValue.COMPLEX_UNIT_SP,mContext.getResources().getDimension(R.dimen.button_font_size));
newButton.setText(question.getAnswer(i, true));
newButton.setTextColor(Color.rgb(255,255,255));
}

changeAnswers();
}

public int getCount()
Expand Down
16 changes: 9 additions & 7 deletions src/com/pikamander2/japanesequiz/QuizActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class QuizActivity extends Activity
int numWrong = 0;
int quizID;
int numAnswerChoices = 4;
boolean romajiFirst = true; //0 = romaji as the question, symbol as the answer. 1 = symbol as the question, romaji as the answer.
DecimalFormat df = new DecimalFormat("#");

Random random = new Random();
ExpandableHeightGridView gridViewQuestions;
Expand Down Expand Up @@ -88,15 +86,15 @@ public void onClick(View view)
{
public void onClick(View view)
{
romajiFirst = !romajiFirst;
question.switchRomajiFirst();
switchQuestionAndAnswers();
}
};

public void switchQuestionAndAnswers()
{
switchQuestion();
questionAdapter.changeAnswers(romajiFirst);
questionAdapter.changeAnswers();
questionAdapter.notifyDataSetChanged();
}

Expand Down Expand Up @@ -130,6 +128,7 @@ private String getPercentCorrect()
return "0";
}

DecimalFormat df = new DecimalFormat("#");
return df.format((100.0 / (numCorrect + numWrong)) * numCorrect);
}

Expand All @@ -143,8 +142,11 @@ public void switchQuestion()
question.shuffleQuestions();
int randNum = random.nextInt(4);

currentQuestion = question.getQuestion(randNum, romajiFirst);
currentAnswer = question.getAnswer(randNum, romajiFirst);
currentQuestion = question.getQuestion(randNum);
currentAnswer = question.getAnswer(randNum);

question.setCurrentAnswer(randNum);

textViewRomaji.setText(currentQuestion);
}

Expand All @@ -169,4 +171,4 @@ public boolean onOptionsItemSelected(MenuItem item)
}
return super.onOptionsItemSelected(item);
}
}
}

0 comments on commit 79d74e6

Please sign in to comment.