建议对针灸建立一个数据模型。
我的附件为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;
}
} |