Hoàng đang thử xây dựng bộ giải đoán này theo mô hình tương tác đối tượng. Đây là thiết kế của lớp Sao Tử vi, các bác xem xét góp ý và chia sẻ ý tưởng.
(class này không đầy đủ cho các sao, chỉ có cho mỗi sao Tử vi, bạn đọc tự hoàn thành hoặc yêu cầu Hoàng gửi bản đủ)
Mã lệnh: Chọn tất cả
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace LySo.TuVi
{
/// <summary>
/// Danh sach cac sao trong khoa Tu vi dau so
/// </summary>
public enum SAOTUVI { NULL, TuVi, LiemTrinh, ThienDong, VuKhuc, ThaiDuong, ThienCo, ThienPhu, ThaiAm, ThamLang, CuMon, ThienTuong, ThienLuong, ThatSat, PhaQuan, LocTon, BacSi, LucSi, ThanhLong, TieuHao, TuongQuan, TauThu, PhiLiem, HiThan, BenhPhu, DaiHao, PhucBinh, QuanPhuLT, ThaiTue, ThieuDuong, TangMon, ThieuAm, QuanPhuTT, TuPhu, TuePha, LongDuc, BachHo, PhucDuc, DieuKhach, TrucPhu, TruongSinh, MocDuc, QuanDoi, LamQuan, DeVuong, Suy, Benh, Tu, Mo, Tuyet, Thai, Duong, KinhDuong, DaLa, DiaKiep, DiaKhong, HoaTinh, LinhTinh, TaPhu, HuuBat, VanXuong, VanKhuc, LongTri, PhuongCac, ThienKhoi, ThienViet, ThienKhoc, ThienHu, TamThai, BatToa, AnQuang, ThienQuy, ThienDuc, NguyetDuc, ThienHinh, ThienRieu, ThienY, HongLoan, ThienHi, QuocAn, DuongPhu, ThienGiai, DiaGiai, GiaiThan };
/// <summary>
/// Phan loai sao trong khoa Tu vi dau so
/// </summary>
public enum LOAISAO { NULL, DeTinh, CatTinh, QuyenTinh, TaiTinh };
/// <summary>
/// Phan loai phuong vi cua sao trong khoa Tu vi dau so
/// </summary>
public enum PHUONGVISAO { NULL, BacDauTinh, NamDauTinh };
/// <summary>
/// Phan loai tinh am duong cua sao trong khoa Tu vi dau so
/// </summary>
public enum TINHAMDUONG { NULL, Duong, Am };
/// <summary>
/// Phan loai ngu hanh cua sao trong khoa Tu vi dau so
/// </summary>
public enum NGUHANHSAO { NULL, Moc, Hoa, Tho, Kim, Thuy };
/// <summary>
/// Tinh chat Mieu dia, Vuong dia, Dac dia, Binh hoa, Ham dia cua sao
/// </summary>
public enum TINHDACHAM { NULL, HamDia, BinhHoa, DacDia, VuongDia, MieuDia };
/// <summary>
/// Vi tri an sao tren La so tu vi
/// </summary>
public enum VITRIANSAO { NULL, Ty, Suu, Dan, Mao, Thin, Ti, Ngo, Mui, Than, Dau, Tuat, Hoi };
/// <summary>
/// Danh sach cac cung so trong khoa Tu vi dau so
/// </summary>
public enum CUNGSOTUVI { NULL, Menh, PhuMau, PhucDuc, DienTrach, QuanLoc, NoBoc, ThienDi, TatAch, TaiBach, TuTuc, PhuThe, HuynhDe, Than };
/// <summary>
/// Nam an Sao trong khoa Tu vi
/// </summary>
public enum NAMANSAO { NULL, GiapTy, AtSuu, BinhDan, DinhMao, MauThin, KyTi, CanhNgo, TanMui, NhamThan, QuyDau, GiapTuat, AtHoi, BinhTy, DinhSuu, MauDan, KyMao, CanhThin, TanTi, NhamNgo, QuyMui, GiapThan, AtDau, BinhTuat, DinhHoi, MauTy, KySuu, CanhDan, TanMao, NhamThin, QuyTi, GiapNgo, AtMui, BinhThan, DinhDau, MauTuat, KyHoi, CanhTy, TanSuu, NhamDan, QuyMao, GiapThin, AtTi, BinhNgo, DinhMui, MauThan, KyDau, CanhTuat, TanHoi, NhamTy, QuySuu, GiapDan, AtMao, BinhThin, DinhTi, MauNgo, KyMui, CanhThan, TanDau, NhamTuat, QuyHoi };
/// <summary>
/// Thang an Sao trong khoa Tu vi
/// </summary>
public enum THANGANSAO { NULL, Mot, Hai, Ba, Bon, Nam, Sau, Bay, Tam, Chin, Muoi, MuoiMot, MuoiHai };
/// <summary>
/// Ngay an Sao trong khoa Tu vi
/// </summary>
public enum NGAYANSAO { NULL, MungMot, MungHai, MungBa, MungBon, MungNam, MungSau, MungBay, MungTam, MungChin, MungMuoi, MuoiMot, MuoiHai, MuoiBa, MuoiBon, MuoiNam, MuoiSau, MuoiBay, MuoiTam, MuoiChin, HaiMuoi, HaiMot, HaiHai, HaiBa, HaiBon, HaiNam, HaiSau, HaiBay, HaiTam, HaiChin, BaMuoi };
/// <summary>
/// Gio an Sao trong khoa Tu vi
/// </summary>
public enum GIOANSAO { NULL, Ty, Suu, Dan, Mao, Thin, Ti, Ngo, Mui, Than, Dau, Tuat, Hoi };
/// <summary>
/// Gioi tinh Nam, Nu
/// </summary>
public enum GIOITINH { NULL, Nam, Nu };
/// <summary>
/// Lop cac sao trong khoa Tu vi dau so
/// </summary>
public class SaoTuVi
{
// Thong tin thoi gian
private NAMANSAO _NamAnSao;
private THANGANSAO _ThangAnSao;
private NGAYANSAO _NgayAnSao;
private GIOANSAO _GioAnSao;
// Thong tin gioi tinh
private GIOITINH _GioiTinh;
// Thong tin chinh ve Sao
private SAOTUVI _SaoTuVi;
private List<LOAISAO> _LoaiSao;
private PHUONGVISAO _PhuongViSao;
private TINHAMDUONG _TinhAmDuong;
private NGUHANHSAO _NguHanhSao;
private TINHDACHAM _TinhDacHam;
private VITRIANSAO _ViTriAnSao;
// Cac thong tin khac ve Sao
private string _TenSao;
private string _YNghia;
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
public SaoTuVi()
{
this._NamAnSao = NAMANSAO.NULL;
this._ThangAnSao = THANGANSAO.NULL;
this._NgayAnSao = NGAYANSAO.NULL;
this._GioAnSao = GIOANSAO.NULL;
this._GioiTinh = GIOITINH.NULL;
this._SaoTuVi = SAOTUVI.NULL;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
public SaoTuVi(SAOTUVI Sao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NAMANSAO.NULL;
this._ThangAnSao = THANGANSAO.NULL;
this._NgayAnSao = NGAYANSAO.NULL;
this._GioAnSao = GIOANSAO.NULL;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="NamAnSao"></param>
public SaoTuVi(SAOTUVI Sao, NAMANSAO NamAnSao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NamAnSao;
this._ThangAnSao = THANGANSAO.NULL;
this._NgayAnSao = NGAYANSAO.NULL;
this._GioAnSao = GIOANSAO.NULL;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="ThangAnSao"></param>
public SaoTuVi(SAOTUVI Sao, THANGANSAO ThangAnSao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NAMANSAO.NULL;
this._ThangAnSao = ThangAnSao;
this._NgayAnSao = NGAYANSAO.NULL;
this._GioAnSao = GIOANSAO.NULL;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="NgayAnSao"></param>
public SaoTuVi(SAOTUVI Sao, NGAYANSAO NgayAnSao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NAMANSAO.NULL;
this._ThangAnSao = THANGANSAO.NULL;
this._NgayAnSao = NgayAnSao;
this._GioAnSao = GIOANSAO.NULL;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="GioAnSao"></param>
public SaoTuVi(SAOTUVI Sao, GIOANSAO GioAnSao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NAMANSAO.NULL;
this._ThangAnSao = THANGANSAO.NULL;
this._NgayAnSao = NGAYANSAO.NULL;
this._GioAnSao = GioAnSao;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="NamAnSao"></param>
/// <param name="ThangAnSao"></param>
/// <param name="NgayAnSao"></param>
/// <param name="GioAnSao"></param>
public SaoTuVi(SAOTUVI Sao, NAMANSAO NamAnSao, THANGANSAO ThangAnSao, NGAYANSAO NgayAnSao, GIOANSAO GioAnSao)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NamAnSao;
this._ThangAnSao = ThangAnSao;
this._NgayAnSao = NgayAnSao;
this._GioAnSao = GioAnSao;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GIOITINH.NULL;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc khoi tao lop SaoTuVi
/// </summary>
/// <param name="Sao"></param>
/// <param name="NamAnSao"></param>
/// <param name="ThangAnSao"></param>
/// <param name="NgayAnSao"></param>
/// <param name="GioAnSao"></param>
/// <param name="GioiTinh"></param>
public SaoTuVi(SAOTUVI Sao, NAMANSAO NamAnSao, THANGANSAO ThangAnSao, NGAYANSAO NgayAnSao, GIOANSAO GioAnSao, GIOITINH GioiTinh)
{
// Khoi tao thong tin thoi gian
this._NamAnSao = NamAnSao;
this._ThangAnSao = ThangAnSao;
this._NgayAnSao = NgayAnSao;
this._GioAnSao = GioAnSao;
// Khoi tao thong tin gioi tinh
this._GioiTinh = GioiTinh;
// Khoi tao thong tin sao
this._SaoTuVi = Sao;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Khoi tao cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc xoa thong tin Sao
/// </summary>
public void ResetThongTin()
{
// Xoa cac thong tin sao
this._SaoTuVi = SAOTUVI.NULL;
this._LoaiSao = new List<LOAISAO>();
this._PhuongViSao = PHUONGVISAO.NULL;
this._TinhAmDuong = TINHAMDUONG.NULL;
this._NguHanhSao = NGUHANHSAO.NULL;
this._TinhDacHam = TINHDACHAM.NULL;
this._ViTriAnSao = VITRIANSAO.NULL;
// Xoa cac thong tin khac
this._TenSao = string.Empty;
this._YNghia = string.Empty;
}
/// <summary>
/// Phuong thuc lay ma Sao
/// </summary>
/// <returns></returns>
public SAOTUVI GetSaoTuVi()
{
return this._SaoTuVi;
}
/// <summary>
/// Phuong thuc thay doi ma Sao
/// </summary>
/// <param name="Sao"></param>
public void SetSaoTuVi(SAOTUVI Sao)
{
this._SaoTuVi = Sao;
}
/// <summary>
/// Phuong thuc lay thong tin nam an sao
/// </summary>
/// <returns></returns>
public NAMANSAO GetNamAnSao()
{
return this._NamAnSao;
}
/// <summary>
/// Phuong thuc thiet lap thong tin nam an sao
/// </summary>
/// <param name="NamAnSao"></param>
public void SetNamAnSao(NAMANSAO NamAnSao)
{
this._NamAnSao = NamAnSao;
}
/// <summary>
/// Phuong thuc lay thong tin thang an sao
/// </summary>
/// <returns></returns>
public THANGANSAO GetThangAnSao()
{
return this._ThangAnSao;
}
/// <summary>
/// Phuong thuc thiet lap thong tin thang an sao
/// </summary>
/// <param name="ThangAnSao"></param>
public void SetThangAnSao(THANGANSAO ThangAnSao)
{
this._ThangAnSao = ThangAnSao;
}
/// <summary>
/// Phuong thuc lay thong tin ngay an sao
/// </summary>
/// <returns></returns>
public NGAYANSAO GetNgayAnSao()
{
return this._NgayAnSao;
}
/// <summary>
/// Phuong thuc thiet lap thong tin ngay an sao
/// </summary>
/// <param name="NgayAnSao"></param>
public void SetNgayAnSao(NGAYANSAO NgayAnSao)
{
this._NgayAnSao = NgayAnSao;
}
/// <summary>
/// Phuong thuc lay thong tin gio an sao
/// </summary>
/// <returns></returns>
public GIOANSAO GetGioAnSao()
{
return this._GioAnSao;
}
/// <summary>
/// Phuong thuc thiet lap thong tin gio an sao
/// </summary>
/// <param name="GioAnSao"></param>
public void SetGioAnSao(GIOANSAO GioAnSao)
{
this._GioAnSao = GioAnSao;
}
/// <summary>
/// Phuong thuc lay thong tin gioi tinh
/// </summary>
/// <returns></returns>
public GIOITINH GetGioiTinh()
{
return this._GioiTinh;
}
/// <summary>
/// Phuong thuc thiet lap thong tin gioi tinh
/// </summary>
/// <param name="GioiTinh"></param>
public void SetGioiTinh(GIOITINH GioiTinh)
{
this._GioiTinh = GioiTinh;
}
/// <summary>
/// Xac dinh vi tri cua sao (an sao), tinh dac ham, loai sao...
/// </summary>
public void AnSao()
{
switch (this._SaoTuVi)
{
case SAOTUVI.TuVi:
if ((this._NamAnSao != NAMANSAO.NULL) && (this._ThangAnSao != THANGANSAO.NULL) && (this._NgayAnSao != NGAYANSAO.NULL) && (this._GioAnSao != GIOANSAO.NULL))
{
// Ma tran so Cuc
int[,] SoCuc = new int[6, 5] { { 2, 6, 5, 3, 4 }, { 6, 5, 3, 4, 2 }, { 3, 4, 2, 6, 5 }, { 5, 3, 4, 2, 6 }, { 4, 2, 6, 5, 3 }, { 6, 5, 3, 4, 2 } };
// Vi tri cung Menh
int x = (14 + (int)this._ThangAnSao - (int)this._GioAnSao) % 12;
// Can nam an sao
int y = ((int)this._NamAnSao - 1) % 10;
// Xac dinh so Cuc
int i = ((x + 1) % 2 + x - 1) / 2;
int j = y % 5;
// Xac dinh vi tri sao Tu vi
int k = ((int)this._NgayAnSao % SoCuc[i, j] == 0) ? (int)this._NgayAnSao / SoCuc[i, j] : ((int)this._NgayAnSao - (int)this._NgayAnSao % SoCuc[i, j]) / SoCuc[i, j] + 1;
int l = ((int)this._NgayAnSao % SoCuc[i, j] == 0) ? 0 : SoCuc[i, j] - (int)this._NgayAnSao % SoCuc[i, j];
int m = (k + 13 + (int)Math.Pow(-1, l) * l) % 12; // m chinh la vi tri cua sao Tu vi
// Vi tri Dac - Ham cua sao Tu vi
TINHDACHAM[] ViTriDacHam = new TINHDACHAM[12] { TINHDACHAM.BinhHoa, TINHDACHAM.DacDia, TINHDACHAM.MieuDia, TINHDACHAM.BinhHoa, TINHDACHAM.VuongDia, TINHDACHAM.VuongDia, TINHDACHAM.MieuDia, TINHDACHAM.DacDia, TINHDACHAM.MieuDia, TINHDACHAM.BinhHoa, TINHDACHAM.VuongDia, TINHDACHAM.VuongDia };
// Loai sao
this._LoaiSao.Add(LOAISAO.DeTinh);
// Phuong vi sao: Bac dau tinh
this._PhuongViSao = PHUONGVISAO.BacDauTinh;
// Tinh am duong: Duong
this._TinhAmDuong = TINHAMDUONG.Duong;
// Ngu hanh: Tho
this._NguHanhSao = NGUHANHSAO.Tho;
// Vi tri an sao
this._ViTriAnSao = (VITRIANSAO)(m + 1);
// Tinh Dac dia, Ham dia
this._TinhDacHam = ViTriDacHam[m];
}
break;
case SAOTUVI.LiemTrinh:
break;
case SAOTUVI.ThienDong:
break;
case SAOTUVI.VuKhuc:
break;
case SAOTUVI.ThaiDuong:
break;
case SAOTUVI.ThienCo:
break;
default:
return;
}
}
}
}
- SaoTuVi = new ThienDong(SAOTUVI.ThienDong) // khởi tạo đối tượng sao Thiên Đồng
Hoặc sử dụng các phương thức khởi dựng khác có kèm thêm ngày tháng năm an sao..., Nếu không thì sử dụng các phương thức Set ngày, tháng an sao, ví dụ:
ThienDong.AnSao() // phương thức thực hiện định vị và tính chất sao.
Kết quả chúng ta sẽ thu đc: vị trí sao, tính đắc hãm, quan hệ sao, loại tính và lời giải đại cương.
Đây là đối tượng cơ sở để hình thành lên đối tượng Cung số tử vi (đề cập sau).