这是个啥
简而言之呢就是最近心血来潮打算自学日语,学日语自然就要先从50音图开始,就是下面这个:
可以看出来50音图横向是按照a i u e o这5个元音顺序,纵向按照a ka sa ta na ha ma ya ra wa 的顺序排布的。按顺序编排自然是为了方便记忆,但是也容易按照顺序能背出来,打乱顺序是否还能快速正确的念出来呢?那我可不可以写个小程序,随机给我出题,让我作答呢?
就类似这样:
mo的写法是:
も
すごい,正しい答!!!
く的读音是:
ku
すごい,正しい答!!!
所以就很简单写了一个小程序。由于我有点强迫症,像ya,ma两行不是完整的5个,所以我还是使用空格填充了,让两个数组看起来整齐一点,所以代码里有対空格的判断跳过。还有有些读音应该是si、ti,我写成了shi和chi,这个看大家自己喜欢吧,可以改。
目前支持以下几项功能:
1.支持输入出多少道题
2.可以根据字形,输入读音;也可以根据读音,输入字形
3.题是随机出的
4.回答错误会给出正确答案
后续大家有兴趣的可以迭代以下几个小功能:
1.目前随机是random函数直接随机的,没有加权重判断,可以增加按照已经出过的题答对答错的次数来增加权重因子,完成错题集的能力
2.日语键盘和英文键盘切换有点麻烦,目前出字形题和字音题是随机的,可以考虑先字形再字音,减少键盘切换的频率
直接上代码
package pri.roy.learn;
import java.util.*;
/**
* @author roy
*/
public class FiftyCharacter {
private static final List<String> PRONOUNCE_LIST = new ArrayList<>(Arrays.asList(
"a", "i", "u", "e", "o",
"ka","ki","ku","ke","ko",
"sa","shi","su","se","so",
"ta","chi","tu","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 final List<String> FONT_LIST = new ArrayList<>(Arrays.asList(
"あ","い","う","え","お",
"か","き","く","け","こ",
"さ","し","す","せ","そ",
"た","ち","つ","て","と",
"な","み","ぬ","ね","の",
"は","ひ","ふ","へ","ほ",
"ま","み","む","め","も",
"や"," ","ゆ"," ","よ",
"ら","り","る","れ","ろ",
"わ"," "," "," ","を",
"ん"
));
public static void main(String[] args) {
Random random = new Random();
Scanner scan = new Scanner(System.in);
System.out.println("请输入要挑战几道题?");
int total = scan.nextInt();
int n;
for(int i = 0;i < total; i++){
n = random.nextInt(PRONOUNCE_LIST.size());
while(" ".equals(FONT_LIST.get(n))){
n = random.nextInt(PRONOUNCE_LIST.size());
}
Boolean flag = random.nextBoolean();
if(flag){
System.out.println(i+1 + "." + FONT_LIST.get(n) + "的读音是:");
}else{
System.out.println(i+1 + "." + PRONOUNCE_LIST.get(n) + "的写法是:");
}
String pronounce = scan.next();
if (flag){
if(pronounce.equals(PRONOUNCE_LIST.get(n))){
System.out.println("すごい,正しい答!!!");
}else{
System.out.println("回答ミス,正解は:" + PRONOUNCE_LIST.get(n));
}
}else{
if(pronounce.equals(FONT_LIST.get(n))){
System.out.println("すごい,正しい答!!!");
}else{
System.out.println("回答ミス,正解は:" + FONT_LIST.get(n));
}
}
}
}
}
测试效果图
---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------
to be a better me, talk is cheap show me the code
版权所有,转载请注明原文链接。
文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【点赞】一下!如果你有更好的建议,可以给我留言讨论,共同进步!文章来源:https://www.toymoban.com/news/detail-459446.html
再次感谢您耐心的读完本篇文章。文章来源地址https://www.toymoban.com/news/detail-459446.html
到了这里,关于自己编写小程序背日语50音图的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!