예제 #1
0
파일: Judge.cs 프로젝트: 1343742392/P
    static public bool Legitimate(Comb comb)
    {
        //是否有组合
        if (comb.type == Comb.PokerType.Without)
        {
            return(false);
        }


        if (beforePoker.type == Comb.PokerType.Empty || !HaveOutPoker())
        {
            return(true);
        }
        //和前面的牌比
        if (comb.type == Comb.PokerType.Bomb)
        {
            if (beforePoker.type != Comb.PokerType.Bomb)
            {
                return(false);
            }
            if (beforePoker.size > comb.size)
            {
                return(false);
            }
            return(true);
        }

        if (beforePoker.length == comb.length && comb.size > beforePoker.size && comb.type == beforePoker.type)
        {
            return(true);
        }

        return(false);
    }
예제 #2
0
파일: AI.cs 프로젝트: 1343742392/P
    ArrayList GreaterPoker()
    {
        ArrayList result       = new ArrayList();
        int       beforeLenght = Judge.beforePoker.length;
        ArrayList havePokers   = GetComponent <PokerManage>().pokers;

        if (!Judge.HaveOutPoker())
        {
            result.Add(havePokers[0]);
            return(result);
        }
        List <int> hpl = new List <int>();

        for (int f = 0; f < havePokers.Count; f++)
        {
            hpl.Add((havePokers[f] as GameObject).GetComponent <PokerAttr>().size);
        }

        if (beforeLenght == 0)
        {
            result.Add(havePokers[0]);
            return(result);
        }

        for (int f = 0; f < havePokers.Count - beforeLenght; f++)
        {
            Comb c = new Comb(hpl.GetRange(f, beforeLenght));
            if (c.type != Comb.PokerType.Without && Judge.Legitimate(c))
            {
                return(havePokers.GetRange(f, beforeLenght));
            }
        }
        return(result);
    }
예제 #3
0
        private void Activate(ExciterOperationMode value)
        {
            operation_ = value;
            switch (operation_)
            {
            case ExciterOperationMode.Barrage:
                Barrage.Activate();
                break;

            case ExciterOperationMode.MultiSpot:
                MultiSpot.Activate();
                break;

            case ExciterOperationMode.Spot:
                Spot.Activate();
                break;

            case ExciterOperationMode.Sweep:
                Sweep.Activate();
                break;

            case ExciterOperationMode.Comb:
                Comb.Activate();
                break;
            }
        }
예제 #4
0
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        n = int.Parse(s[0]);
        a = int.Parse(s[1]);
        b = int.Parse(s[2]);
        int at = a, bt = b;

        a = Math.Max(at, bt);
        b = Math.Min(at, bt);
        k = long.Parse(s[3]);
        int  mod = 998244353;
        Comb c   = new Comb(n, mod);
        long ans = 0;

        for (long r = 0; r <= Math.Min(k / a, n); r++)
        {
            if ((k - a * r) % b != 0)
            {
                continue;
            }
            long bl = (k - a * r) / b;
            if (bl > n)
            {
                continue;
            }
            ans += (c.comb((int)r) * c.comb((int)bl)) % mod;
            ans  = ans % mod;
        }
        Console.WriteLine(ans);
    }
예제 #5
0
파일: PokerManage.cs 프로젝트: 1343742392/P
    public void outPokerBtnBack(string result)
    {
        if (result == ButtonManage.ButtonNames.OutPoker)
        {
            buttonMange.GetComponent <ButtonManage>().SetButtons(new string[] { });
            List <int> l = new List <int>();
            foreach (GameObject gameObject in upPokers)
            {
                l.Add(gameObject.GetComponent <PokerAttr>().size);
            }
            Comb c = new Comb(l);
            if (!Judge.Legitimate(c))
            {
                Debug.Log("no");
                return;
            }


            OutPoker(upPokers);

            Judge.beforePoker = c;
            upPokers.RemoveRange(0, upPokers.Count);
            RefreshPoker();
            alldPoker.GetComponent <AllPoker>().outPokerEnd(gameObject);
        }
        else
        {
            mIsNext = true;
            Sprite s = Resources.Load <Sprite>("img/next");
            ShowWord.Say(new Vector3(0, -50, 0), s, delegate()
            {
                alldPoker.GetComponent <AllPoker>().outPokerEnd(gameObject);
            });
        }
    }
예제 #6
0
        public void CombinationGreaterTest()
        {
            // Arrange
            Card[] cards1 = new Card[5];
            Card[] cards2 = new Card[5];
            Card[] cards3 = new Card[5];
            Card[] cards4 = new Card[5];

            // Act
            cards1[0].Set(1, 3);
            cards1[1].Set(2, 0);
            cards1[2].Set(3, 2);
            cards1[3].Set(4, 2);
            cards1[4].Set(5, 0);

            cards2[0].Set(1, 3);
            cards2[1].Set(2, 0);
            cards2[2].Set(3, 2);
            cards2[3].Set(4, 2);
            cards2[4].Set(5, 0);

            cards3[0].Set(6, 3);
            cards3[1].Set(6, 0);
            cards3[2].Set(9, 2);
            cards3[3].Set(9, 2);
            cards3[4].Set(1, 1);

            cards4[0].Set(1, 3);
            cards4[1].Set(1, 0);
            cards4[2].Set(2, 2);
            cards4[3].Set(2, 1);
            cards4[4].Set(2, 2);

            Comb combination1 = new Comb(cards1);
            Comb combination2 = new Comb(cards2);
            Comb combination3 = new Comb(cards3);
            Comb combination4 = new Comb(cards4);

            // Assert
            Console.WriteLine("\n1\n{0}\n", combination1.ToString());
            Console.WriteLine("\n2\n{0}\n", combination2.ToString());
            Console.WriteLine("\n3\n{0}\n", combination3.ToString());
            Console.WriteLine("\n4\n{0}\n", combination4.ToString());

            Assert.IsFalse(combination1 < combination1);
            Assert.IsFalse(combination1 < combination2);
            Assert.IsFalse(combination1 < combination3);
            Assert.IsFalse(combination2 < combination1);
            Assert.IsFalse(combination2 < combination2);
            Assert.IsFalse(combination2 < combination3);
            Assert.IsFalse(combination3 < combination3);
            Assert.IsFalse(combination4 < combination1);
            Assert.IsFalse(combination4 < combination2);
            Assert.IsFalse(combination4 < combination3);
            Assert.IsFalse(combination4 < combination4);
            Assert.IsTrue(combination1 < combination4);
            Assert.IsTrue(combination2 < combination4);
            Assert.IsTrue(combination3 < combination1);
        }
예제 #7
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests COMB by generating all 3-subsets of a 5 set.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    01 April 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int k = 3;
        int       l;
        const int n = 5;

        int lmax = FullertonLib.i4_binom(n, k);

        Console.WriteLine("");
        Console.WriteLine("TEST01");
        Console.WriteLine("  Generate all K-subsets of an N set.");
        Console.WriteLine("  K = " + k + "");
        Console.WriteLine("  N = " + n + "");
        Console.WriteLine("  LMAX =" + lmax + "");

        if (!typeMethods.i4_choose_check(n, k))
        {
            Console.WriteLine("");
            Console.WriteLine("TEST01 - Warning!");
            Console.WriteLine("  The binomial coefficient cannot be");
            Console.WriteLine("  computed in integer arithmetic for");
            Console.WriteLine("  this choice of parameters.");
            return;
        }

        Console.WriteLine("");

        for (l = 1; l <= lmax; l++)
        {
            int[]  c    = Comb.comb(n, k, l);
            string cout = "  " + l.ToString().PadLeft(4) + ":  ";
            int    i;
            for (i = 0; i < k; i++)
            {
                cout += "  " + c[i].ToString().PadLeft(4);
            }

            Console.WriteLine(cout);
        }
    }
예제 #8
0
    static void Main(string[] args)
    {
        string[] inputArr = Console.ReadLine().Split(' ');
        int      k        = int.Parse(Console.ReadLine());

        // Comb.CombsNoReps(inputArr, k);
        Comb.CombsWReps(inputArr, k);
    }
예제 #9
0
        public void Operators()
        {
            var left  = new Comb("38ad9d83-0b00-b248-adad-413fa7cd5e0f");
            var right = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");

            Assert.IsTrue(left < right);
            Assert.IsFalse(left > right);
        }
예제 #10
0
        public void NewCombTest()
        {
            DateTime now  = DateTime.Now;
            Guid     id   = Comb.NewComb();
            DateTime time = Comb.GetDateFromComb(id);

            Assert.IsTrue(time.Subtract(now).TotalSeconds < 1);
        }
예제 #11
0
    public static void comb_next_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    COMB_NEXT_TEST tests COMB_NEXT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    10 April 2009
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 5;

        int[] a = new int[N];
        int   k;

        Console.WriteLine("");
        Console.WriteLine("COMB_NEXT_TEST");
        Console.WriteLine("  COMB_NEXT produces combinations.");

        for (k = 1; k <= N; k++)
        {
            Console.WriteLine("");
            Console.WriteLine("  Combinations of size K = " + k + "");
            Console.WriteLine("");

            bool done = true;

            for (;;)
            {
                Comb.comb_next(N, k, a, ref done);

                if (done)
                {
                    break;
                }

                string cout = "";
                int    i;
                for (i = 0; i < k; i++)
                {
                    cout += "  " + a[i].ToString().PadLeft(4);
                }

                Console.WriteLine(cout);
            }
        }
    }
예제 #12
0
            public bool Parse(string format, out Comb result)
            {
                if (format == "X")
                {
                    return this.TryParseHex(out result);
                }

                return this.TryParse(format, out result);
            }
예제 #13
0
파일: Event.cs 프로젝트: ceferrari/backend
 protected Event(Type type, object message, int version = 1)
 {
     Timestamp     = DateTime.UtcNow.ToString("O");
     Type          = type.Name;
     Message       = message;
     UniqueId      = Comb.NewComb().ToString();
     CorrelationId = Comb.NewComb().ToString();
     Version       = version.ToString();
 }
예제 #14
0
파일: CombTests.cs 프로젝트: vip32/cadru
        public void Constructors()
        {
            var c = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");
            ExceptionAssert.Throws<FormatException>(() => new Comb("3e3a6e75-0100-0f45-ae41a3e3d2536a57"));
            Assert.AreEqual("38ba4a03-0b00-b248-baa3-413faadaa2b8", c.ToString());

            c = new Comb();
            Assert.AreEqual(Comb.Empty, c);
        }
예제 #15
0
파일: CombTests.cs 프로젝트: lanicon/cadru
        public void Constructors()
        {
            var c = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");
            Assert.ThrowsException<FormatException>(() => new Comb("3e3a6e75-0100-0f45-ae41a3e3d2536a57"));
            Assert.AreEqual("38ba4a03-0b00-b248-baa3-413faadaa2b8", c.ToString());

            c = new Comb();
            Assert.AreEqual(Comb.Empty, c);
        }
예제 #16
0
파일: 2742789.cs 프로젝트: qifanyyy/CLCDSA
    static void Main()
    {
        int  n   = ReadInt();
        int  k   = ReadInt();
        Comb c   = new Comb(n + k - 1, mod);
        long ans = c.Com(n + k - 1, k);

        WriteLine(ans);
    }
예제 #17
0
        public void ToByteArray()
        {
            var c = Comb.Parse("385175e2-0b00-b248-911d-413fa76b7979");
            var a = c.ToByteArray();

            Assert.IsNotNull(a);
            Assert.AreEqual(16, a.Length);
            CollectionAssert.AllItemsAreNotNull(a);
            CollectionAssert.AreEqual(new byte[] { 56, 81, 117, 226, 11, 0, 178, 72, 145, 29, 65, 63, 167, 107, 121, 121 }, a);
        }
예제 #18
0
        static void Main(string[] args)
        {
            int n = 10, m = 5, numThread = 4;

            Console.WriteLine(Comb.P(n));
            Console.WriteLine(Comb.A(n, m));
            Console.WriteLine(Comb.C(n, m));
            Console.WriteLine(Comb.P(n, numThread));
            Console.WriteLine(Comb.A(n, m, numThread));
            Console.WriteLine(Comb.C(n, m, numThread));
        }
예제 #19
0
        public void TryParseExact()
        {
            Comb c;

            Assert.IsTrue(Comb.TryParseExact("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}", "X", out c));
            Assert.IsTrue(Comb.TryParseExact("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}", "x", out c));

            Assert.IsTrue(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "N", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "n", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "n", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-01000f45ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e750100-0f45ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45-ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45ae41-a3e3d2536a57", "n", out c));

            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "D", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-01000f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "d", out c));

            Assert.IsTrue(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "B", out c));
            Assert.IsTrue(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-01000f45ae41a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45ae41a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41a3e3d2536a57}", "b", out c));

            Assert.IsTrue(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "P", out c));
            Assert.IsTrue(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-01000f45ae41a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45ae41a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41a3e3d2536a57)", "p", out c));

            Assert.IsFalse(Comb.TryParseExact(null, "d", out c));
            Assert.IsFalse(Comb.TryParseExact("(00000000000000000000000000000000)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "x", out c));

            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a573e", "x", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a", "x", out c));

            ExceptionAssert.Throws <FormatException>(() => Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "e", out c));
        }
예제 #20
0
        public void Parse()
        {
            Assert.IsInstanceOfType(Comb.Parse("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.Parse("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.Parse("3e3a6e7501000f45ae41a3e3d2536a57"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.Parse("3e3a6e75-0100-0f45-ae41-a3e3d2536a57"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.Parse("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.Parse("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)"), typeof(Comb));

            ExceptionAssert.Throws <ArgumentNullException>(() => Comb.Parse(null));
            ExceptionAssert.Throws <FormatException>(() => Comb.Parse("(00000000000000000000000000000000)"));
        }
예제 #21
0
        public void TryParse()
        {
            Assert.IsTrue(Comb.TryParse("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}", out var c));
            Assert.IsTrue(Comb.TryParse("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}", out c));
            Assert.IsTrue(Comb.TryParse("3e3a6e7501000f45ae41a3e3d2536a57", out c));
            Assert.IsTrue(Comb.TryParse("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", out c));
            Assert.IsTrue(Comb.TryParse("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", out c));
            Assert.IsTrue(Comb.TryParse("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", out c));

            Assert.IsFalse(Comb.TryParse(null, out c));
            Assert.IsFalse(Comb.TryParse("(00000000000000000000000000000000)", out c));
        }
예제 #22
0
 internal static void InMenu()
 {
     Caiy = MainMenu.AddMenu("Caitlyn", "Caitlyn");
     Caiy.Add("AutoAtack", new CheckBox("Use Atack Buff [Enemy]"));
     pre = Caiy.AddSubMenu("Prediction");
     pre.Add("HitQ", new ComboBox("HitChance [Q]", 1, "Low", "Medium", "High"));
     pre.Add("HitW", new ComboBox("HitChance [W]", 2, "Low", "Medium", "High"));
     pre.Add("HitE", new ComboBox("HitChance [E]", 1, "Low", "Medium", "High"));
     Comb = Caiy.AddSubMenu("Combo");
     Comb.Add("Qc", new CheckBox("Use [Q]"));
     Comb.Add("Wc", new CheckBox("Use [W]"));
     Comb.Add("Ec", new CheckBox("Use [E]"));
     Comb.AddSeparator();
     Comb.AddLabel("Settings [R]");
     Comb.Add("Rf", new CheckBox("Use [R] Fish Enemy"));
     Comb.AddSeparator();
     Comb.Add("ModoR", new ComboBox("Mode [R]", 0, "Fish [R]", "Beta Mode [R]"));
     Comb.AddSeparator();
     Comb.AddLabel("Settings [Beta Mode R]");
     Comb.Add("LR", new Slider("Minimal of the Enemy's Life", 20, 1, 100));
     Comb.AddSeparator();
     Comb.AddLabel("Enemys, No Use on whom?");
     foreach (var enemies in EntityManager.Heroes.Enemies.Where(caity => !caity.IsMe))
     {
         Comb.Add("CaitlynUti" + enemies.ChampionName, new CheckBox("" + enemies.ChampionName, false));
     }
     Auto = Caiy.AddSubMenu("Auto Harass");
     Auto.Add("AutoQ", new CheckBox("AutoHarass [Q]"));
     Auto.AddSeparator();
     Auto.AddLabel("Mana Percent");
     Auto.Add("ManaQ", new Slider("Mana Percent [Q] > {0}", 65, 1));
     Lane = Caiy.AddSubMenu("Lane [Clear]");
     Lane.Add("Ql", new CheckBox("Use [Q] Lane"));
     Lane.AddSeparator();
     Lane.AddLabel("Mana Percent");
     Lane.Add("ManaL", new Slider("Mana Percent > {0}", 50, 1, 100));
     Lane.AddSeparator();
     Lane.AddLabel("Minions");
     Lane.Add("Qmi", new Slider("Minion Percent > {0}", 3, 1, 6));
     Jungle = Caiy.AddSubMenu("Jungle [Clear]");
     Jungle.Add("Qj", new CheckBox("Use [Q] Jungle"));
     Jungle.AddSeparator();
     Jungle.AddLabel("Mana Percent");
     Jungle.Add("Q/J", new Slider("Mana Percent [Q/E]", 65, 1));
     Misc = Caiy.AddSubMenu("Misc");
     Misc.Add("Ks", new CheckBox("KillSteal"));
     Draws = Caiy.AddSubMenu("Draws [Spells]");
     Draws.Add("DQ", new CheckBox("[Q] Draws"));
     Draws.Add("DW", new CheckBox("[W] Draws"));
     Draws.Add("DE", new CheckBox("[E] Draws"));
     Draws.Add("DR", new CheckBox("[R] Draws"));
 }
예제 #23
0
        public CartCreateCommand(CartViewModel cart)
            : base(Comb.NewComb())
        {
            CustomerId = cart.CustomerId;
            Status     = DomainValues.Cart.Status.Pending;
            Item       = new CartCreateUpdateItem
            {
                Sku      = cart.Item.Sku,
                Quantity = cart.Item.Quantity
            };

            Validator = new CartCreateCommandValidator(this);
        }
예제 #24
0
파일: CombTests.cs 프로젝트: vip32/cadru
        public void CompareTo()
        {
            var a = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");
            var b = new Comb("385175e2-0b00-b248-911d-413fa76b7979");
            var c = new Comb("385175e2-0b00-b248-911d-413fa76b7979");

            Assert.AreEqual(1, a.CompareTo(b));
            Assert.AreEqual(-1, b.CompareTo(a));
            Assert.AreEqual(0, b.CompareTo(c));

            Assert.AreEqual(1, a.CompareTo(null));
            Assert.AreEqual(1, a.CompareTo((object)b));

            ExceptionAssert.Throws<ArgumentException>(() => a.CompareTo("test"));
        }
예제 #25
0
 private static void ComboMenu()
 {
     Comb = Menu.AddSubMenu("Combo");
     Comb.Add("Q", new CheckBox("Use Q"));
     Comb.Add("W", new CheckBox("Use W"));
     Comb.Add("E", new CheckBox("Use E"));
     Comb.Add("R", new CheckBox("Use R"));
     Comb.AddSeparator();
     Comb.AddLabel("Settings [R]");
     Comb.Add("RQ", new CheckBox("Use R (Q)"));
     Comb.Add("RW", new CheckBox("Use R (W)", false));
     Comb.Add("RE", new CheckBox("Use R (E)"));
     Comb.AddLabel("Combos");
     Comb.Add("Key1", new KeyBind("Combo [2]", false, KeyBind.BindTypes.HoldActive, 'G'));
 }
예제 #26
0
        public void CompareTo()
        {
            var a = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");
            var b = new Comb("385175e2-0b00-b248-911d-413fa76b7979");
            var c = new Comb("385175e2-0b00-b248-911d-413fa76b7979");

            Assert.AreEqual(1, a.CompareTo(b));
            Assert.AreEqual(-1, b.CompareTo(a));
            Assert.AreEqual(0, b.CompareTo(c));

            Assert.AreEqual(1, a.CompareTo(null));
            Assert.AreEqual(1, a.CompareTo((object)b));

            ExceptionAssert.Throws <ArgumentException>(() => a.CompareTo("test"));
        }
예제 #27
0
        public void NewComb()
        {
            var comb = Comb.NewComb();

            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(DateTime.UtcNow.Date, comb.DateTime.Date);

            var date = DateTime.Parse("2014-06-23 09:46:0.0");

            comb = Comb.NewComb(date);
            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(date, comb.DateTime.LocalDateTime);

            var offset = new DateTimeOffset(date);

            comb = Comb.NewComb(offset);
            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(offset, comb.DateTime.LocalDateTime);

            //comb = new Comb2("3e3a6e75-0100-0f45-ae41-a3e3d2536a57");
            //Assert.AreEqual("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", comb.ToString());
            //Assert.AreEqual(new DateTimeOffset(2014, 06, 25, 14, 43, 45, 550, TimeSpan.Zero), comb.DateTime);

            //s = SequentialGuid.NewSequentialGuid();
            //var d = s.GetDateTimeOffset();

            //Assert.AreNotEqual("00000000-0000-0000-0000-000000000000", s.ToString());
            //Assert.AreEqual(DateTime.Today.Date, s.GetDateTime().Date);

            int count = 10;

            var list = new List <Comb>(count);

            for (int i = 0; i < count; i++)
            {
                var c = Comb.NewComb();
                list.Add(c);
                Console.WriteLine("{0} - {1}", c.ToString(), c.DateTime.ToString("o"));
                Thread.Sleep(325);
            }

            Console.WriteLine("Sorted:");
            list.Sort();
            foreach (var c in list)
            {
                Console.WriteLine("{0} - {1}", c.ToString(), c.DateTime.ToString("o"));
            }
        }
예제 #28
0
        public ProductCreateCommand(ProductViewModel product)
            : base(Comb.NewComb())
        {
            Sku              = product.Sku;
            Name             = product.Name;
            ShortDescription = product.ShortDescription;
            LongDescription  = product.LongDescription;
            ImageUrl         = product.ImageUrl;
            Price            = new ProductPrice
            {
                Amount       = product.Price.Amount,
                Scale        = product.Price.Scale,
                CurrencyCode = product.Price.CurrencyCode
            };

            Validator = new ProductCreateCommandValidator(this);
        }
예제 #29
0
파일: CombTests.cs 프로젝트: lanicon/cadru
        public void ParseExact()
        {
            Assert.IsInstanceOfType(Comb.ParseExact("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}", "X"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}", "x"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "N"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "n"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "D"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", ""), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "B"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "P"), typeof(Comb));
            Assert.IsInstanceOfType(Comb.ParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p"), typeof(Comb));

            Assert.ThrowsException<ArgumentNullException>(() => Comb.Parse(null));
            Assert.ThrowsException<FormatException>(() => Comb.Parse("(00000000000000000000000000000000)"));
            Assert.ThrowsException<FormatException>(() => Comb.ParseExact("3e3a6e75-0100-0f45-ae41a3e3d2536a57", "x"));
        }
예제 #30
0
    public static void comb_row_next_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    COMB_ROW_NEXT_TEST tests COMB_ROW_TEST.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 December 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       n;
        const int N_MAX = 10;

        Console.WriteLine("");
        Console.WriteLine("COMB_ROW_NEXT_TEST");
        Console.WriteLine("  COMB_ROW_NEXT computes the next row of the Pascal triangle.");
        Console.WriteLine("");

        int[] c = new int[N_MAX + 1];

        for (n = 0; n <= N_MAX; n++)
        {
            Comb.comb_row_next(n, ref c);
            string cout = "  " + n.ToString().PadLeft(2) + "  ";
            int    i;
            for (i = 0; i <= n; i++)
            {
                cout += c[i].ToString().PadLeft(5);
            }

            Console.WriteLine(cout);
        }
    }
예제 #31
0
파일: CombTests.cs 프로젝트: lanicon/cadru
        public void Equality()
        {
            var left = Comb.NewComb();
            var right = Comb.NewComb();

            Assert.IsTrue(left != right);
            Assert.IsFalse(left == right);

            right = left;
            Assert.IsTrue(left == right);
            Assert.IsTrue(left.Equals(right));
            Assert.IsTrue(left.Equals((object)right));
            Assert.IsFalse(left.Equals(null));
            Assert.IsFalse(left.Equals("test"));

            var hash = Comb.Parse("385175e2-0b00-b248-911d-413fa76b7979");
            Assert.AreEqual(1917962195, hash.GetHashCode());
            Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
            Assert.AreNotEqual(left.GetHashCode(), hash.GetHashCode());
        }
예제 #32
0
        void specToCSV_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.InitialDirectory = workFolder;
            saveFile.AddExtension     = true;
            saveFile.DefaultExt       = "csv";
            saveFile.Filter           = "CSV Files (*.csv)|*.csv";

            saveFile.ShowDialog(this);

            string file = saveFile.FileName;

            try
            {
                Comb.writeSpectrum(dataReal, file, this.Text);
            }
            catch { }



            //throw new NotImplementedException();
        }
예제 #33
0
파일: CombTests.cs 프로젝트: lanicon/cadru
        public void NewComb()
        {
            var comb = Comb.NewComb();
            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(DateTime.UtcNow.Date, comb.DateTime.Date);

            var date = DateTime.Parse("2014-06-23 09:46:0.0");

            comb = Comb.NewComb(date);
            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(date, comb.DateTime.LocalDateTime);

            var offset = new DateTimeOffset(date);
            comb = Comb.NewComb(offset);
            Assert.AreNotEqual(Comb.Empty, comb);
            Assert.AreEqual(offset, comb.DateTime.LocalDateTime);

            var count = 10;

            var list = new List<Comb>(count);

            for (var i = 0; i < count; i++)
            {
                var c = Comb.NewComb();
                list.Add(c);
                Console.WriteLine("{0} - {1}", c.ToString(), c.DateTime.ToString("o"));
                Thread.Sleep(325);
            }

            Console.WriteLine("Sorted:");
            list.Sort();
            foreach (var c in list)
            {
                Console.WriteLine("{0} - {1}", c.ToString(), c.DateTime.ToString("o"));
            }
        }
예제 #34
0
            private bool TryParseHex(out Comb result)
            {
                ulong a, b, c;
                result = new Comb();

                if (!(this.ParseChar('{')
                && this.ParseHexPrefix()
                && this.ParseHex(8, false, out a)
                && this.ParseCharWithWhiteSpaces(',')
                && this.ParseHexPrefix()
                && this.ParseHex(4, false, out b)
                && this.ParseCharWithWhiteSpaces(',')
                && this.ParseHexPrefix()
                && this.ParseHex(4, false, out c)
                && this.ParseCharWithWhiteSpaces(',')
                && this.ParseCharWithWhiteSpaces('{')))
                {
                    return false;
                }

                var d = new byte[8];
                for (int i = 0; i < d.Length; ++i)
                {
                    ulong dd;

                    if (!(this.ParseHexPrefix() && this.ParseHex(2, false, out dd)))
                    {
                        return false;
                    }

                    d[i] = (byte)dd;

                    if (i != 7 && !this.ParseCharWithWhiteSpaces(','))
                    {
                        return false;
                    }
                }

                if (!(this.ParseCharWithWhiteSpaces('}') && this.ParseCharWithWhiteSpaces('}')))
                {
                    return false;
                }

                if (!this.EOF)
                {
                    return false;
                }

                result = new Comb((int)a, (short)b, (short)c, d);
                return true;
            }
예제 #35
0
            private bool TryParse(string format, out Comb result)
            {
                ulong a, b, c;
                result = new Comb();

                if ((format == "B" && !this.ParseChar('{')) || (format == "P" && !this.ParseChar('(')))
                {
                    return false;
                }

                if (!this.ParseHex(8, true, out a))
                {
                    return false;
                }

                var hasHyphen = FormatHasHyphen(format);

                if (hasHyphen && !this.ParseChar('-'))
                {
                    return false;
                }

                if (!this.ParseHex(4, true, out b))
                {
                    return false;
                }

                if (hasHyphen && !this.ParseChar('-'))
                {
                    return false;
                }

                if (!this.ParseHex(4, true, out c))
                {
                    return false;
                }

                if (hasHyphen && !this.ParseChar('-'))
                {
                    return false;
                }

                var d = new byte[8];
                for (int i = 0; i < d.Length; i++)
                {
                    ulong dd;
                    if (!this.ParseHex(2, true, out dd))
                    {
                        return false;
                    }

                    if (i == 1 && hasHyphen && !this.ParseChar('-'))
                    {
                        return false;
                    }

                    d[i] = (byte)dd;
                }

                if ((format == "B" && !this.ParseChar('}')) || (format == "P" && !this.ParseChar(')')))
                {
                    return false;
                }

                if (!this.EOF)
                {
                    return false;
                }

                result = new Comb((int)a, (short)b, (short)c, d);
                return true;
            }
예제 #36
0
            public bool Parse(out Comb result)
            {
                string format = String.Empty;

                switch (this.sourceLength)
                {
                    case 32:
                        format = "N";
                        break;

                    case 36:
                        format = "D";
                        break;

                    case 38:
                        switch (this.source[0])
                        {
                            case '{':
                                format = "B";
                                break;

                            case '(':
                                format = "P";
                                break;
                        }

                        break;
                }

                if (this.TryParse(format, out result))
                {
                    return true;
                }

                this.Reset();
                return this.TryParseHex(out result);
            }
예제 #37
0
파일: CombTests.cs 프로젝트: vip32/cadru
        public void Operators()
        {
            var left = new Comb("38ad9d83-0b00-b248-adad-413fa7cd5e0f");
            var right = new Comb("38ba4a03-0b00-b248-baa3-413faadaa2b8");

            Assert.IsTrue(left < right);
            Assert.IsFalse(left > right);
        }