バイオリズムって何?
http://www2.cc.niigata-u.ac.jp/~takeuchi/tbasic/BackGround/Biorythm.html
を参考にした。
バイオリズムとは生まれた日から一定の周期で体調が変化している、という学説らしい
体は23日、感情は28日、知性は33日周期でぐるぐるするらしい
c#の日付関係の使いやすさにビビった。
using System; using System.Text; public class Rhythm { public double Physical; public double Sensitivity; public double Intellectual; public readonly int _retstate; public Rhythm(double p, double s, double i, int state) { this.Physical = p; this.Sensitivity = s; this.Intellectual = i; this._retstate = state; } public override string ToString() { StringBuilder st = new StringBuilder(); st.Append("Physical :" + this.Physical + "\n"); st.Append("Sensitivity:" + this.Sensitivity + "\n"); st.Append("Intelectual:" + this.Intellectual + "\n"); return st.ToString(); } } class Bio { private const int physicalPeriod = 23; private const int sensitivityPeriod = 28; private const int intelligencePeriod = 33; public static Rhythm getBioRhythm(DateTime now, DateTime birth) { int ts = Convert.ToInt16((now - birth).TotalDays); //非常識な入力の時もあるでしょ。 if (ts < 1) return new Rhythm(0.0, 0.0, 0.0, -1); double p, s, i; p = Math.Sin(ts * Math.PI / physicalPeriod); s = Math.Sin(ts * Math.PI / sensitivityPeriod); i = Math.Sin(ts * Math.PI / intelligencePeriod); return new Rhythm(p, s, i, 0); } }
main
string birthDate = "1981/08/05 19:31";//ここは標準入力からとった、という仮定 DateTime birth; DateTime.TryParse(birthDate, out birth); Rhythm retR = Bio.getBioRhythm(DateTime.Now,birth);
retRにいろいろ入ってます。
ループを回してサインカーブを作ればいいと思うよ!
うまく動くといいですね。