建議對針灸建立一個數(shù)據模型。
我的附件為Najia未完成的代碼.
歡迎提供文字偽代碼
import java.util.Date;
public class Najia {
public static String tiangan[] =
{ "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
public static String dizhi[] =
{ "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戍", "亥" };
public static String najia[] =
{ "甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午", "辛未", "壬申", "癸酉", "甲戍", "乙亥",
"丙子", "丁丑", "戊寅", "己卯", "庚辰", "辛巳", "壬午", "癸未", "甲申", "乙酉", "丙戍", "丁亥",
"戊子", "己丑", "庚寅", "辛卯", "壬辰", "癸巳", "甲午", "乙未", "丙申", "丁酉", "戊戍", "己亥",
"庚子", "辛丑", "壬寅", "癸卯", "甲辰", "乙巳", "丙午", "丁未", "戊申", "己酉", "庚戍", "辛亥",
"壬子", "癸丑", "甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戍", "癸亥" };
public static int yjiazhi = 1984;
public Najia() {
}
//打印六十甲子代碼
public static void main(String[] args) {
printNajia();
System.out.println("癸亥的下一個是" + getNextJiaZhi("癸亥"));
System.out.println("\n2005年的干支是: " + getYearNajia(2005));
System.out.println("\n1976年的干支是: " + najia[getYearNajia(1976)]);
System.out.println("\n1984年的干支是: " + najia[getYearNajia(1984)]);
}
public static void printNajia() {
int i = 0, x = 0, y = 0;
StringBuffer temp = new StringBuffer();
System.out.print("\n");
for (i = 0; i < 60; i++) {
if ((i % 10) == 0)
temp.append("\n");
if (x == 10)
x = 0;
if (y == 12)
y = 0;
temp.append(tiangan[x]).append(dizhi[y]).append(" ");
//if((i%10)==0)System.out.print("\n");
//System.out.print("\""+temp+"\",");
x++;
y++;
}
temp.append("\n");
System.out.print(temp.toString());
}
public static String getNextJiaZhi(String jz) {
int i = 0;
if (jz != null && jz.length() > 0) {
while (i < 60) {
if (najia[i].equals(jz)) {
if (i == 59)
return najia[0];
return najia[i + 1];
}
i++;
}
}
return null;
}
public static String[] getNajia() {
return najia;
}
public static String[] getTianGan() {
return tiangan;
}
public static String[] getDiZhi() {
return dizhi;
}
public static String timeNajia(Date date) {
return null;
}
public static int getYearNajia(int year) {
int idx = 0;
//idx=Math.abs(yjiazhi-year)% 60;
if (year == yjiazhi) {
return 0;
}
if (year > yjiazhi) {
idx = (year - yjiazhi);
} else {
idx = (yjiazhi - year);
}
if(idx>60) {idx=idx%60;}
idx = 60 - idx;
return idx;
}
public static int getMonthNajia(int year,int month){
return 0;
}
}
附件: 你需要登錄才可以下載或查看附件。沒有帳號?注冊