android 根据生日生成星座

来源:互联网 发布:js购物车结算 编辑:程序博客网 时间:2024/06/01 08:45
小菜比,第一次写博客
<span style="font-size:14px;">String[][] constellations = {{"摩羯座", "水瓶座"}, {"水瓶座", "双鱼座"}, {"双鱼座", "白羊座"}, {"白羊座", "金牛座"}, {"金牛座", "双子座"}, {"双子座", "巨蟹座"}, {"巨蟹座", "狮子座"},        {"狮子座", "处女座"}, {"处女座", "天秤座"}, {"天秤座", "天蝎座"}, {"天蝎座", "射手座"}, {"射手座", "摩羯座"}};//星座分割时间int[] date = {20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22};//星座生成 传进是日期格式为: yyyy-mm-ddpublic void getConstellations(String birthday) {    String[] data = birthday.split("-");    int day = date[Integer.parseInt(data[1]) - 1];    String[] cl1 = constellations[Integer.parseInt(data[1]) - 1];    if (Integer.parseInt(data[2]) >= day) {        become_constellation.setText(cl1[1]);    } else {        become_constellation.setText(cl1[0]);    }}</span>


1 0
原创粉丝点击