DESKTOP-E68IKVH_20200829-魏海荣

一、遇到问题:

seek 方法中,当year的年龄小于基准值时怎么办?

    public static String seek( int year ) {
    int k = (year - CONTRAST) % 60 ;
    int j = k % 10;
    int i = k % 12;
    String str =  HEAVENLY_STEMS [j]  +" "+  EARTHLY_BRANCHES[i] ;
    
    return str;
}

解决问题

public static String seek(int year) {
        int k = (year - CONTRAST) % 60;
        if (k >= 0) {
            int j = k % 10;
            int i = k % 12;
            String str = HEAVENLY_STEMS[j] + " " + EARTHLY_BRANCHES[i];
            return str;
        }else {
            int j = (10 + k) % 10;
            int i = (12 + k) % 12;
            String str = HEAVENLY_STEMS[j] + " " + EARTHLY_BRANCHES[i];
            return str;
        }
}

二、吐槽:

​ 依然是那么的热啊,希望能好好整整空调。

标签

© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1