当前位置:网站首页>国学*周易*梅花易数 代码实现效果展示 - 梅花心易
国学*周易*梅花易数 代码实现效果展示 - 梅花心易
2022-08-05 03:34:00 【星梦天河】
近日偶遇 舒涵老师 《国学*周易》4天免费试听课,带着一颗好奇心,看了2晚直播;
第1课入门周易基础知识;
第2课讲梅花易数;
听完梅花易数,突来灵感,随机报2个数字,根据公式测算凶吉;感觉就是一道编程题,于是第2天工作,花了一个上午也出了公式,下面展示一下执行效果。
- 报数:32,57;得到以下执行结果:
- >>>> 说明这是 上课出的题目,此处用于验证个人的公式对不对!
用 * > *
---------
体 * > *
输入(32,57) ===> [原卦](**) ===> [变卦](**)
测算(32,57) ===> 依始运势:大吉,事易成! 未来走势:小凶,事难成!
MSG(32,57) ===> At the beginning: very good, it is so easy! At the end: I think it is difficult!
- 报数:22,44;得到以下执行结果:
- >>>> 说明这是 2022-08-02 佩洛西窜访中国台湾地区的飞机落地时间,相信未走势完全有利于中方
用 * > *
---------
体 * > *
输入(22,44) ===> [原卦](**) ===> [变卦](**)
测算(22,44) ===> 依始运势:大吉,事易成! 未来走势:大吉,事易成!
MSG(22,44) ===> At the beginning: very good, it is so easy! At the end: very good, it is so easy!
- 报数:18,22;得到以下执行结果:
- >>>> 说明公司聚会常去 十八二十二 这家店,猜想此店老板有风水学问,这2个数字肯定大吉,果不其然!!
用 * > *
---------
体 * > *
输入(18,22) ===> [原卦](**) ===> [变卦](**)
测算(18,22) ===> 依始运势:大吉,事易成! 未来走势:大吉,事易成!
MSG(18,22) ===> At the beginning: very good, it is so easy! At the end: very good, it is so easy!
核心代码:
package org.gitee.zhouyi.enums;
import lombok.Getter;
import java.util.Arrays;
/**
* 八卦定义:(乾1-兑2-离3-震4-巽5-坎6-艮7-坤8)
* 卦象(乾111-兑011-离101-震001-巽110-坎010-艮100-坤000)
* 五行(乾1金-兑2金-离3火-震4木-巽5木-坎6水-艮7土-坤8土)
* @author: mengxin
* @date: 2022/8/3 8:11
*/
@Getter
public enum EightGua {
QAN(1, "乾", "111", FiveXing.JIN, "*"),
DUI(2, "兑", "011", FiveXing.JIN, "*"),
LI(3, "离", "101", FiveXing.HUO, "*"),
ZHEN(4, "震", "001", FiveXing.MU, "*"),
XUN(5, "巽", "110", FiveXing.MU, "*"),
KAN(6, "坎", "010", FiveXing.SHUI, "*"),
GEN(7, "艮", "100", FiveXing.TU, "*"),
KUN(0, "坤", "000", FiveXing.TU, "*");
private int order;
private String name;
private String chart;
private FiveXing fiveXing;
private String logo;
EightGua(int order, String name, String chart, FiveXing fiveXing, String logo){
this.order = order;
this.name = name;
this.chart = chart;
this.fiveXing = fiveXing;
this.logo = logo;
}
/**
* 根据序号获取
* @param order
* @return
*/
public static EightGua getByOrder(int order){
return Arrays.stream(EightGua.values()).filter(row -> row.getOrder() == order).findAny().orElse(null);
}
/**
* 根据卦图获取
* @param chart
* @return
*/
public static EightGua getByChart(String chart){
return Arrays.stream(EightGua.values()).filter(row -> row.getChart().equals(chart)).findAny().orElse(null);
}
}
package org.gitee.zhouyi.enums;
import lombok.Getter;
/**
* 五行相生相克定义: 木 火 土 金 水
* 五行生克图(木s火k土,火s土k金,土s金k水,金s水k木,水s木k火)
* @author: mengxin
* @date: 2022/8/3 8:20
*/
@Getter
public enum FiveXing {
MU("木", FiveElement.HUO, FiveElement.TU),
HUO("火", FiveElement.TU, FiveElement.JIN),
TU("土", FiveElement.JIN, FiveElement.SHUI),
JIN("金", FiveElement.SHUI, FiveElement.MU),
SHUI("水", FiveElement.MU, FiveElement.HUO);
private String name;
private FiveElement better;
private FiveElement worse;
/**
* 定义
* @param name 名称
* @param better 相生
* @param worse 相克
*/
FiveXing(String name, FiveElement better, FiveElement worse){
this.name = name;
this.better = better;
this.worse = worse;
}
//五行定义
public enum FiveElement {
MU("木", FiveXing.MU),
HUO("火", FiveXing.HUO),
TU("土", FiveXing.TU),
JIN("金", FiveXing.JIN),
SHUI("水", FiveXing.SHUI);
private String name;
private FiveXing xing;
FiveElement(String name, FiveXing xing){
this.name = name;
this.xing = xing;
}
}
}
package org.gitee.zhouyi.enums;
import lombok.Getter;
/**
* 六爻:用体定义
* @author: mengxin
* @date: 2022/8/3 8:56
*/
@Getter
public enum SixYao {
TY1("体用合一", "大吉,事易成!", "very good, it is so easy!"),
YST("用生体", "大吉,事易成!", "very good, it is so easy!"),
YKT("用克体", "大凶,事不成!", "I think it is no way!"),
TSY("体生用", "小凶,事难成!", "I think it is difficult!"),
TKY("体克用", "小吉,事可成!", "I think it can be done!");
private String name;
private String zhDesc;
private String desc;
SixYao(String name, String zhDesc, String desc){
this.name = name;
this.zhDesc = zhDesc;
this.desc = desc;
}
/**
* 根据上爻与下爻计算YaoDef
* @param first
* @param second
* @return
*/
public static SixYao getYaoDef(FiveXing first, FiveXing second){
if(first==second){
return SixYao.TY1;
}else if(FiveXing.MU==first && FiveXing.HUO==second){
//木生火 -> 体生用
return SixYao.TSY;
}else if(FiveXing.MU==first && FiveXing.TU==second){
//土生木 -> 体生用
return SixYao.TSY;
}else if(FiveXing.MU==first && FiveXing.JIN==second){
//金克木 -> 体克用
return SixYao.TKY;
}else if(FiveXing.MU==first && FiveXing.SHUI==second){
//水生木 -> 体生用
return SixYao.TSY;
}else if(FiveXing.HUO==first && FiveXing.MU==second){
//木生火 -> 体生用
return SixYao.TSY;
}else if(FiveXing.HUO==first && FiveXing.TU==second){
//火生土 -> 用生体
return SixYao.YST;
}else if(FiveXing.HUO==first && FiveXing.JIN==second){
//火克金 -> 用克体
return SixYao.YKT;
}else if(FiveXing.HUO==first && FiveXing.SHUI==second){
//水克火 -> 体克用
return SixYao.TKY;
}else if(FiveXing.TU==first && FiveXing.MU==second){
//土生木 -> 用生体
return SixYao.YST;
}else if(FiveXing.TU==first && FiveXing.HUO==second){
//火生土 -> 体生用
return SixYao.TSY;
}else if(FiveXing.TU==first && FiveXing.JIN==second){
//土生金 -> 用生体
return SixYao.YST;
}else if(FiveXing.TU==first && FiveXing.SHUI==second){
//土克水 -> 用克体
return SixYao.YKT;
}else if(FiveXing.JIN==first && FiveXing.MU==second){
//金克木 -> 用克体
return SixYao.YKT;
}else if(FiveXing.JIN==first && FiveXing.HUO==second){
//火克金 -> 体克用
return SixYao.TKY;
}else if(FiveXing.JIN==first && FiveXing.TU==second){
//土生金 -> 体生用
return SixYao.TSY;
}else if(FiveXing.JIN==first && FiveXing.SHUI==second){
//金生水 -> 用生体
return SixYao.YST;
}else if(FiveXing.SHUI==first && FiveXing.MU==second){
//水生木 -> 用生体
return SixYao.YST;
}else if(FiveXing.SHUI==first && FiveXing.HUO==second){
//水克火 -> 用克体
return SixYao.YKT;
}else if(FiveXing.SHUI==first && FiveXing.TU==second){
//土克水 -> 体克用
return SixYao.TKY;
}else if(FiveXing.SHUI==first && FiveXing.JIN==second){
//金生水 -> 体生用
return SixYao.TSY;
}
return null;
}
}
package org.gitee.zhouyi.pojo;
import lombok.Getter;
import lombok.Setter;
import org.gitee.zhouyi.enums.EightGua;
import org.gitee.zhouyi.enums.FiveXing;
import org.gitee.zhouyi.enums.SixYao;
import java.io.Serializable;
/**
* 测算结果定义
* @author: mengxin
* @date: 2022/8/3 11:18
*/
@Getter
@Setter
public class PlumResult implements Serializable {
private Integer start;
private Integer end;
private EightGua firstGua;
private EightGua secondGua;
private EightGua firstNewGua;
private EightGua secondNewGua;
/*
用 {A1}>{A2}
------------
体 {B1}>{B2}
*/
public String getProcess() {
String upStrFormat = "用 {A1} > {A2}\n";
String centerStr = "---------\n";
String downStrFormat = "体 {B1} > {B2}\n";
String upStr = upStrFormat.replace("{A1}", firstGua.getLogo()).replace("{A2}", firstNewGua.getLogo());
String downStr = downStrFormat.replace("{B1}", secondGua.getLogo()).replace("{B2}", secondNewGua.getLogo());
StringBuffer sb = new StringBuffer();
sb.append(upStr);
sb.append(centerStr);
sb.append(downStr);
return sb.toString();
}
public String getProcess2() {
String processStr = String.format("输入(%s,%s) ===> [原卦](%s%s) ===> [变卦](%s%s)", start, end, firstGua.getLogo(), secondGua.getLogo(), firstNewGua.getLogo(), secondNewGua.getLogo());
return processStr;
}
public String getResult() {
//5.分用体 6.标五行
FiveXing firstFX = firstGua.getFiveXing();
FiveXing secondFX = secondGua.getFiveXing();
FiveXing firstNewFX = firstNewGua.getFiveXing();
FiveXing secondNewFX = secondNewGua.getFiveXing();
//7.定吉凶
SixYao orgSixYao = SixYao.getYaoDef(firstFX, secondFX);
SixYao newSixYao = SixYao.getYaoDef(firstNewFX, secondNewFX);
//8.出结果
String result = String.format("测算(%s,%s) ===> 依始运势:%s 未来走势:%s", start, end, orgSixYao.getZhDesc(), newSixYao.getZhDesc());
return result;
}
public String getMessage() {
//5.分用体 6.标五行
FiveXing firstFX = firstGua.getFiveXing();
FiveXing secondFX = secondGua.getFiveXing();
FiveXing firstNewFX = firstNewGua.getFiveXing();
FiveXing secondNewFX = secondNewGua.getFiveXing();
//7.定吉凶
SixYao orgSixYao = SixYao.getYaoDef(firstFX, secondFX);
SixYao newSixYao = SixYao.getYaoDef(firstNewFX, secondNewFX);
//8.出结果
String result = String.format("MSG(%s,%s) ===> At the beginning: %s At the end: %s", start, end, orgSixYao.getDesc(), newSixYao.getDesc());
return result;
}
}
以后有需要测算凶吉的朋友,可以找我代劳哈!!!
边栏推荐
- YYGH-13-客服中心
- ffmpeg pixel format basics
- 2022 High-level installation, maintenance, and removal of exam questions mock exam question bank and online mock exam
- Package zip is not available, but is referred to by another package.
- Solana NFT开发指南
- Summary of common methods of arrays
- Burp installation and proxy settings
- presto启动成功后出现2022-08-04T17:50:58.296+0800 ERROR Announcer-3 io.airlift.discovery.client.Announcer
- [GYCTF2020]EasyThinking
- Slapped in the face: there are so many testers in a certain department of byte
猜你喜欢
Shell script: for loop and the while loop
public static <T> List<T> asList(T... a) 原型是怎么回事?
How to Add Category-Specific Widgets in WordPress
2022-08-04 第六小组 瞒春 学习笔记
36-Jenkins-Job Migration
MySql的索引学习和使用;(本人觉得足够详细)
龙蜥社区第二届理事大会圆满召开!理事换届选举、4 位特约顾问加入
Web3.0 Dapps——通往未来金融世界的道路
2022 High-level installation, maintenance, and removal of exam questions mock exam question bank and online mock exam
数据库设计的酸(ACID)碱(BASE)原则
随机推荐
Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
ffmpeg pixel format basics
Ffmpeg - sources analysis
龙蜥社区第二届理事大会圆满召开!理事换届选举、4 位特约顾问加入
Slapped in the face: there are so many testers in a certain department of byte
Web3.0 Dapps - the road to the future financial world
用Unity发布APP到Hololens2无坑教程
sql怎么找字段里所有数据为空的字段
结构体初解
Android interview question - how to write with his hands a non-blocking thread safe queue ConcurrentLinkedQueue?
ffmpeg -sources分析
How to solve the three major problems of bank data collection, data supplementary recording and index management?
Leading the highland of digital medicine, Zhongshan Hospital explores to create a "new paradigm" for future hospitals
测试薪资这么高?刚毕业就20K
Android Practical Development - Kotlin Tutorial (Introduction - Login Function Implementation 3.3)
The most effective seven performance testing techniques of software testing techniques
十五. 实战——mysql建库建表 字符集 和 排序规则
905. Interval selection
Ali's local life's single-quarter revenue is 10.6 billion, Da Wenyu's revenue is 7.2 billion, and Cainiao's revenue is 12.1 billion
[Filter tracking] based on matlab unscented Kalman filter inertial navigation + DVL combined navigation [including Matlab source code 2019]