/// <summary> /// 计算式结果显示输出 /// </summary> /// <param name="formulas">计算式</param> public void ConsoleFormulas(FruitsLinkageFormula formulas) { LogUtil.LogDebug(MessageUtil.GetMessage(() => MsgResources.I0004T, "水果連連看")); int index = 0; formulas.FruitsFormulas.ToList().ForEach(d => { Console.WriteLine(string.Format("水果:{0} {1} {2} = {3} 容器編號:{4}", CommonUtil.GetValue(CommonLib.Util.GapFilling.Left, d.LeftParameter, d.Gap), d.Sign.ToOperationString(), CommonUtil.GetValue(CommonLib.Util.GapFilling.Right, d.RightParameter, d.Gap), CommonUtil.GetValue(CommonLib.Util.GapFilling.Answer, d.Answer, d.Gap), formulas.Seats[index++])); }); int seat = 0; formulas.Sort.ToList().ForEach(d => { Formula container = formulas.ContainersFormulas[d]; CommonLib.Util.GapFilling gap = container.Gap; Console.WriteLine(string.Format("容器{0}:{1} {2} {3} = {4}", seat++, CommonUtil.GetValue(CommonLib.Util.GapFilling.Left, container.LeftParameter, gap), container.Sign.ToOperationString(), CommonUtil.GetValue(CommonLib.Util.GapFilling.Right, container.RightParameter, gap), CommonUtil.GetValue(CommonLib.Util.GapFilling.Answer, container.Answer, gap))); }); }
/// <summary> /// 題型構築 /// </summary> /// <param name="p">題型參數</param> public override void MarkFormulaList(FruitsLinkageParameter p) { // 標準題型(指定單個運算符) if (p.FourOperationsType == FourOperationsType.Standard) { // 計算式作成(指定單個運算符實例) MarkFormulaList(p, () => { return(p.Signs[0]); }); } else { // 計算式作成(加減乘除運算符實例隨機抽取) MarkFormulaList(p, () => { return(p.Signs[CommonUtil.GetRandomNumber(0, p.Signs.Count - 1)]); }); } // 水果連連看對象實例 FruitsLinkageFormula fruitsLinkageFormula = new FruitsLinkageFormula { // 左邊水果算式 FruitsFormulas = _fruitsFormulas, // 右側容器算式 ContainersFormulas = _containersFormulas, // 座位號隨機排序 Sort = _seats.OrderBy(x => Guid.NewGuid()).ToList() }; // 容器的擺放位置 fruitsLinkageFormula.Seats = GetNewSeats(fruitsLinkageFormula.Sort); // 結果設定 p.Formulas = fruitsLinkageFormula; }
/// <summary> /// 初期化參數 /// </summary> public override void InitParameter() { // 集合實例化 Formulas = new FruitsLinkageFormula(); }