合婚アルゴリズムJAVAで本命卦合婚法を実現

11937 ワード

質問:私は男性の誕生日を入力します:1980-01-01 01:01女性の誕生日:1980-01-01:01
ひざまずいてこのような8字の結婚のアルゴリズムを求めます
合婚ソフトは多いようですが、肝心なのはどのように書くか、アルゴリズムを書くかです.ネット上には似たような文章はほとんどありません.
易学の達人である私(マスター♂羅荘)は、私たちがどのように結婚ソフトウェアを作るかを教えてくれる責任があります.
アルゴリズムの説明:
今では多くの田舎の占い師が呂才合婚法や本命卦合婚法を使っている.
私の先生が教えてくれたのも本命卦合婚法で、
このアルゴリズムは多くのバージョンがあって、私のここは中華易帆風順研究院の斉炳権先生のアルゴリズムを採用します
オリジナル:http://blog.sina.com.cn/s/blog_62a4f99c0102dygx.html一.本命卦数理:カン1、坤2、震3、巽4、中宮5(男坤、女艮)、乾6、兑7、艮8、离9.
二.中華易帆風順研究院の斉炳権先生は、男性:11-出生年横加(流年玄空飛星入中宮計算式)女性:4+出生年横加の例:1989年生まれ男性:11-(1+9+8+9)=11-(27)=11-(2+7)=2、つまり本命卦は坤卦;1989年生まれの女性:4+(1+9+8+9)=4+(27)=4+9=(13)=1+3=4、本命卦は巽卦.2012年生まれの男性:11-(2+0+1+2)=11-5=6、本命卦は乾卦;2012年生まれの女性:4+(2+0+1+2)=4+5=9、本命卦を離卦とする. 
結果は原文を見ることができる
ここはポイントコードで実現しただけです
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luozhuanghehun;

/**
 *      
 *
 * @author luozhuang   ♂  
 */
public class Luozhuanghehun {

    enum sex {

        man,
        woman;
    }

    enum basicstring {

         ,  ,  ,  ,  ,  ,  ,  ;
    }

    public String hehun(String man, String woman) {
        if (man.length() != 4 || woman.length() != 4) {
            return "     ";
        }

        return  peihun(getnumber(man,sex.man), getnumber(woman,sex.woman));

    }

    public  String peihun(String man, String woman) {
      return  peihun(getnumber(man,sex.man), getnumber(woman,sex.woman));
    }
    private String peihun(int man, int woman) {
        basicstring mang = basicsnumber(man, sex.man);
        basicstring womang = basicsnumber(woman, sex.woman);

        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }


        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //           ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //           ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //           ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //              ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //              ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //              ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //              ,       。
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }



        //               ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //              ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //            ,       。
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }



        //            ,       。
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //            ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //       ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //       ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //       ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


//                  ,       ;
//
//           ,       ;
//
//           ,       ;
//
//           ,       。

        if (mang == womang) {
            return "   ";
        }

        //        ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //        ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //        ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //        ,       。;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }

        //        ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //         ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //         ,       ;
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }


        //             ,       。
        if (mang == basicstring.  && womang == basicstring. ) {
            return "   ";
        }
        if (womang == basicstring.  && mang == basicstring. ) {
            return "   ";
        }
        return "     ";

    }

    /**      
     *
     * @param number   
     * @param isman    
     * @return     
     */
    public Luozhuanghehun.basicstring basicsnumber(int number, sex isman) {
        switch (number) {
            case 1:
                return basicstring. ;

            case 2:
                return basicstring. ;
            case 3:
                return basicstring. ;
            case 4:
                return basicstring. ;
            case 5:
                if (isman == sex.man) {
                    return basicstring. ;
                } else {
                    return basicstring. ;
                }
            case 6:
                return basicstring. ;
            case 7:
                return basicstring. ;
            case 8:
                return basicstring. ;
            case 9:
                return basicstring. ;

        }
        return null;
    }

    /**
     *   :11-     (               )   :4+     
     * 1989      :11-(1+9+8+9)=11-(27)=11-(2+7)=2,       
     *
     * @param year       
     * @return   getnumber
     */
    public int getnumber(String year, sex isman) throws NumberFormatException {

        int yearnumber = Short.parseShort(year);
        return getnumber(yearnumber,isman);

    }

    /**
     *   :11-     (               )   :4+     
     * 1989      :11-(1+9+8+9)=11-(27)=11-(2+7)=2,       
     *
     * @param year       
     * @return     
     */
    public int getnumber(int year, sex isman) {

        int m = ((int) (year / 1000) % 10);
        int h = ((int) (year / 100) % 10);
        int s = ((int) (year / 10) % 10);
        int g = year % 10;
        int sum = m + h + g + s;
         int result;
          if (isman == sex.man) {
                       result = 11 - ((int) (sum / 10) % 10) - (sum % 10);
                       
                } else {
                    result = 4+ ((int) (sum / 10) % 10) + (sum % 10);
                }
          if(result>10)
          {
      result=result-9;//    10,        ,     
          }
        return result;

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Luozhuanghehun my = new Luozhuanghehun();
        String result=my.hehun("1956", "1856");
        System.out.println(my.getnumber("1956",sex.man));
        System.out.println(my.basicsnumber(my.getnumber("1956",sex.man),sex.man));
        
          System.out.println(my.getnumber("1856",sex.woman));
        System.out.println(my.basicsnumber(my.getnumber("1856",sex.woman),sex.woman));
        System.out.println(result);
    }
}