Skip to content

Instantly share code, notes, and snippets.

@syneart
Last active March 31, 2016 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syneart/f6b94d1fc9fb49246bd3 to your computer and use it in GitHub Desktop.
Save syneart/f6b94d1fc9fb49246bd3 to your computer and use it in GitHub Desktop.
星座判斷
public class Constellation_main {
public static void main(String[] args) {
System.out.println(getConstellationFromDate("10/01"));
}
private static String getConstellationFromDate(String strBirthday) {
int intBirthday = Integer.valueOf(strBirthday.replace("/",""));
if (intBirthday < 11 | intBirthday > 1231) {
return "博愛座";
}
if (intBirthday < 121 | intBirthday > 1221) {
return "摩羯座";
} else if (intBirthday < 219) {
return "水瓶座";
} else if (intBirthday < 321) {
return "雙魚座";
} else if (intBirthday < 420) {
return "牡羊座";
} else if (intBirthday < 521) {
return "金牛座";
} else if (intBirthday < 622) {
return "雙子座";
} else if (intBirthday < 723) {
return "巨蟹座";
} else if (intBirthday < 823) {
return "獅子座";
} else if (intBirthday < 923) {
return "處女座";
} else if (intBirthday < 1024) {
return "天秤座";
} else if (intBirthday < 1123) {
return "天蠍座";
} else if (intBirthday < 1222) {
return "射手座";
} else {
return "博愛座";
}
}
}
@wangdu1005
Copy link

so cool!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment