コード例 #1
0
        public void CanGenerateNumbers()
        {
            OddEven oddEven = new OddEven();
            var     result  = oddEven.PrintNumbers();

            result.Should().NotBeNullOrWhiteSpace();
        }
コード例 #2
0
        public void CanGenerateNumbersRange(int startNumber, int finishNumber)
        {
            OddEven oddEven = new OddEven();
            var     result  = oddEven.PrintNumbers(startNumber, finishNumber);

            result.Should().NotBeNullOrWhiteSpace();
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: jmarkova/ITCareer
        public void IsTwoEven()
        {
            // Arrage
            OddEven sample = new OddEven();

            // Act & Assert
            Assert.IsTrue(sample.IsEven(2));
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: jmarkova/ITCareer
        public void IsOneOdd()
        {
            // Arrage
            OddEven sample = new OddEven();

            // Act & Assert
            Assert.IsTrue(sample.IsOdd(1));
        }
コード例 #5
0
        public void IsValidatingEvenNumbers(int input, bool expected)
        {
            // ARRANGE
            var oddeven = new OddEven();

            // ACT
            var result = oddeven.IsEvenNumber(input);

            // ASSERT
            Assert.AreEqual(expected, result);
        }
コード例 #6
0
        private int[] NullifyWrongTypeNumbers(int[] array, OddEven type)
        {
            for (var i = 0; i < array.Length; i++)
            {
                if (!IsType(array[i], type))
                {
                    array[i] = 0;
                }
            }

            return(array);
        }
コード例 #7
0
 public OddEven SwitchOddEven(OddEven oddEven)
 {
     if (oddEven == OddEven.Any)
     {
         return(oddEven);
     }
     if (oddEven == OddEven.Even)
     {
         return(OddEven.Odd);
     }
     return(OddEven.Even);
 }
コード例 #8
0
        internal Payout DeterminePayoutForEvenOdd(Slot slot, OddEven betchoice)
        {
            if (slot.OddOrEvent == betchoice)
            {
                return(new Payout {
                    PayOff = 1, Amount = _betAmount * 2
                });
            }

            return(new Payout {
                PayOff = 0, Amount = 0
            });
        }
コード例 #9
0
 public int RandomNextInt(int maxNumber, OddEven oddEven)
 {
     while (true)
     {
         var number = _random.Next(maxNumber) + 1;
         if (oddEven == OddEven.Any ||
             oddEven == OddEven.Even && number % 2 == 0 ||
             oddEven == OddEven.Odd && number % 2 == 1)
         {
             return(number);
         }
     }
 }
コード例 #10
0
ファイル: OddEven.cs プロジェクト: CharlieWeld/CSharpLabs
    public static void Main(string[] args)
    {
        int number;
        System.Console.Write("Enter a number to determine if it is odd or even: ");
        number = int.Parse(System.Console.ReadLine());

        OddEven oeObj = new OddEven();

        if (oeObj.determineOddOrEven(number))
        {
            System.Console.WriteLine("The number is even");
        }
        else
        {
            System.Console.WriteLine("The number is ODD!");
        }
    }
コード例 #11
0
        private OddEven GetLineType(int lineIndex, OddEven firstLineType)
        {
            var type = firstLineType == OddEven.Even ? GetOddEvenType(lineIndex) : GetOddEvenType(lineIndex + 1);

            return(type);
        }
コード例 #12
0
 private bool IsType(int value, OddEven type)
 {
     return(GetOddEvenType(value) == type);
 }
コード例 #13
0
        public void Given_a_prime_number_return_number(string expected, int number)
        {
            var result = OddEven.Print(number);

            Assert.AreEqual(expected, result);
        }
コード例 #14
0
        public void Given_an_odd_number_return_string_Odd(string expected, int number)
        {
            var result = OddEven.Print(number);

            Assert.AreEqual(expected, result);
        }
コード例 #15
0
ファイル: frmMain_wj.ex.cs プロジェクト: github188/myitoppsp
        /// <summary>
        /// 根据设备关系创建线路
        /// </summary>
        /// <param name="device">变电站图元</param>
        /// <param name="devicSUID">变电站设备ID</param>
        void createLine(XmlElement device, string devicSUID)
        {
            string projectid = Itop.Client.MIS.ProgUID;
            string strCon    = string.Format(" where Type = '01' and projectid='{0}' and svguid='{1}'", projectid, devicSUID);
            IList  list      = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            // SvgElementCollection list2 = tlVectorControl1.SVGDocument.CurrentLayer.GraphList.Clone();// tlVectorControl1.SVGDocument.SelectNodes("svg/use");
            XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
            float       scale = tlVectorControl1.ScaleRatio;

            //scale = 1;
            foreach (PSPDEV dev in list)
            {
                foreach (SvgElement element in list2)
                {
                    if (!(element is Use))
                    {
                        continue;
                    }
                    ///XmlElement element = node as XmlElement;
                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    string deviceid = (element).GetAttribute("Deviceid");
                    if (string.IsNullOrEmpty(deviceid))
                    {
                        continue;
                    }
                    if (devicSUID == deviceid)
                    {
                        continue;
                    }
                    string strCon1 = string.Format(" where Type = '01' and projectid='{0}' and svguid='{1}'", projectid, deviceid); //" where projectid='" + projectid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                    string label   = element.GetAttribute("info-name");
                    IList  list3   = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon1);
                    foreach (PSPDEV pd in list3)
                    {
                        // if (dev.Number != pd.Number)
                        {
                            string strCon2 = " where projectid = '" + projectid + "' AND Type = '05' AND IName = '" + dev.Name + "' AND JName = '" + pd.Name + "'";
                            IList  list4   = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2);

                            string strCon3 = "where projectid = '" + projectid + "' AND Type = '05' AND IName = '" + pd.Name + "' AND JName = '" + dev.Name + "'";
                            IList  list5   = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            float  width   = ((IGraph)element).GetBounds().Width / 3;
                            for (int i = 0; i < list4.Count; i++)
                            {
                                //判断次图上是否已经有此线路
                                XmlNodeList xnl = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@Deviceid='" + ((PSPDEV)list4[i]).SUID + "']");
                                if (xnl.Count > 0)
                                {
                                    continue;
                                }
                                PointF[] t2    = new PointF[] { ((IGraph)device).CenterPoint, ((IGraph)element).CenterPoint };
                                float    angel = 0f;

                                angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);
                                PointF pStart1 = new PointF(((IGraph)device).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180)));
                                PointF pStart2 = new PointF(((IGraph)device).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180)));

                                PointF pStart3 = new PointF(((IGraph)element).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180)));
                                PointF pStart4 = new PointF(((IGraph)element).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180)));

                                string temp = "";
                                if (i == 0)
                                {
                                    temp = ((IGraph)device).CenterPoint.X.ToString() + " " + ((IGraph)device).CenterPoint.Y.ToString() + "," + ((IGraph)element).CenterPoint.X + " " + ((IGraph)element).CenterPoint.Y.ToString();
                                }
                                else if (OddEven.IsOdd(i))
                                {
                                    temp = pStart1.X.ToString() + " " + pStart1.Y.ToString() + "," + pStart3.X.ToString() + " " + pStart3.Y.ToString();
                                }
                                else if (OddEven.IsEven(i))
                                {
                                    temp = pStart2.X.ToString() + " " + pStart2.Y.ToString() + "," + pStart4.X.ToString() + " " + pStart4.Y.ToString();
                                }
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;

                                n1.SetAttribute("points", temp);
                                n1.SetAttribute("IsLead", "1");

                                n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                //决定线路在那条图层上:本级图层中有包含“线路”两字的图层,则生成到此图层; 如果有多个包含“线路”的图层,则生成到第一个; 如果没有包含“线路”的图层,则生成到当前选择图层。
                                //ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                                ArrayList layercol = frmlar.getBrotherLayers();
                                bool      jsflag   = false;
                                for (int m = 0; m < layercol.Count; m++)
                                {
                                    if ((layercol[m] as Layer).GetAttribute("id") == SvgDocument.currentLayer && !(layercol[m] as Layer).GetAttribute("label").Contains("线路"))
                                    {
                                        continue;
                                    }
                                    else if ((layercol[m] as Layer).GetAttribute("id") != SvgDocument.currentLayer && !(layercol[m] as Layer).GetAttribute("label").Contains("线路"))
                                    {
                                        continue;
                                    }
                                    else if ((layercol[m] as Layer).GetAttribute("id") == SvgDocument.currentLayer && (layercol[m] as Layer).GetAttribute("label").Contains("线路"))
                                    {
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        jsflag = true;
                                        break;
                                    }
                                    else if ((layercol[m] as Layer).GetAttribute("id") != SvgDocument.currentLayer && (layercol[m] as Layer).GetAttribute("label").Contains("线路"))
                                    {
                                        n1.SetAttribute("layer", (layercol[m] as Layer).GetAttribute("id"));
                                        jsflag = true;
                                        break;
                                    }
                                }
                                if (!jsflag)
                                {
                                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                                }

                                n1.SetAttribute("FirstNode", device.GetAttribute("id"));
                                n1.SetAttribute("LastNode", element.GetAttribute("id"));
                                n1.SetAttribute("Deviceid", ((PSPDEV)list4[i]).SUID);
                                SetPolyLineType(n1, (PSPDEV)list4[i]);
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                //n1.RemoveAttribute("layer");
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.SVGDocument.CurrentElement = element as SvgElement;
                            }
                            int j = 0;
                            if (list4 != null)
                            {
                                j = list4.Count;
                            }
                            for (int i = j; i < j + list5.Count; i++)
                            {
                                //判断次图上是否已经有此线路
                                XmlNodeList xnl = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@Deviceid='" + ((PSPDEV)list5[i - j]).SUID + "']");
                                if (xnl.Count > 0)
                                {
                                    continue;
                                }
                                PointF[] t2    = new PointF[] { ((IGraph)element).CenterPoint, ((IGraph)device).CenterPoint };
                                float    angel = 0f;
                                angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);
                                PointF pStart1 = new PointF(((IGraph)element).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180)));
                                PointF pStart2 = new PointF(((IGraph)element).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180)));

                                PointF pStart3 = new PointF(((IGraph)device).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180)));
                                PointF pStart4 = new PointF(((IGraph)device).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180)));
                                string temp    = "";
                                if (i == 0)
                                {
                                    temp = ((IGraph)element).CenterPoint.X.ToString() + " " + ((IGraph)element).CenterPoint.Y.ToString() + "," + ((IGraph)device).CenterPoint.X + " " + ((IGraph)device).CenterPoint.Y.ToString();
                                }
                                else if (OddEven.IsOdd(i))
                                {
                                    temp = pStart1.X.ToString() + " " + pStart1.Y.ToString() + "," + pStart3.X.ToString() + " " + pStart3.Y.ToString();
                                }
                                else if (OddEven.IsEven(i))
                                {
                                    temp = pStart2.X.ToString() + " " + pStart2.Y.ToString() + "," + pStart4.X.ToString() + " " + pStart4.Y.ToString();
                                }
                                //ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                                ArrayList  layercol = frmlar.getBrotherLayers();
                                XmlElement n1       = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                n1.SetAttribute("points", temp);
                                n1.SetAttribute("IsLead", "1");
                                n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                bool jsflag = false;
                                for (int m = 0; m < layercol.Count; m++)
                                {
                                    if ((layercol[m] as Layer).ID == SvgDocument.currentLayer && !(layercol[m] as Layer).Label.Contains("线路"))
                                    {
                                        continue;
                                    }
                                    else if ((layercol[m] as Layer).ID != SvgDocument.currentLayer && !(layercol[m] as Layer).Label.Contains("线路"))
                                    {
                                        continue;
                                    }
                                    else if ((layercol[m] as Layer).ID == SvgDocument.currentLayer && (layercol[m] as Layer).Label.Contains("线路"))
                                    {
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        jsflag = true;
                                        break;
                                    }
                                    else if ((layercol[m] as Layer).ID != SvgDocument.currentLayer && (layercol[m] as Layer).Label.Contains("线路"))
                                    {
                                        n1.SetAttribute("layer", (layercol[m] as Layer).ID);
                                        jsflag = true;
                                        break;
                                    }
                                }
                                if (!jsflag)
                                {
                                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                                }
                                n1.SetAttribute("FirstNode", element.GetAttribute("id"));
                                n1.SetAttribute("LastNode", device.GetAttribute("id"));
                                n1.SetAttribute("Deviceid", ((PSPDEV)list5[i - j]).SUID);
                                SetPolyLineType(n1, (PSPDEV)list5[i - j]);
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                //n1.RemoveAttribute("layer");
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.SVGDocument.CurrentElement = element as SvgElement;
                            }
                        }
                    }
                }
            }
        }