Exemplo n.º 1
0
        private ObservableCollection <SuiteModel> GetSuites()
        {
            List <string> contains = new List <string>();

            contains.Add("[Transacao]");
            contains.Add("][Manter");

            List <Suite> list = null;

            try
            {
                list = controller.SuiteListByContais(contains, 2);
            }
            catch {
                list = controller.SuiteListByContais(contains, 2);
            }

            foreach (var item in list)
            {
                try
                {
                    Suites.Add(new SuiteModel(item));
                }
                catch {
                    var n = item.Nome;
                }
            }
            Suites = Suites;
            return(Suites);
        }
Exemplo n.º 2
0
        internal static NUnitTest GetSetupTestTarget(Bundle bundle)
        {
            var       suiteName = bundle == null ? null : bundle.GetString("suite");
            TestSuite suite     = null;

            if (suiteName != null && !Suites.TryGetValue(suiteName, out suite))
            {
                Console.WriteLine("Invalid suite name: {0}", suiteName);
                Console.WriteLine("Supported suite names:");
                foreach (KeyValuePair <string, TestSuite> e in Suites)
                {
                    Console.WriteLine("\t{0}", e.Key);
                }
                return(new TestSuite("__error__"));
            }
            if (suite != null)
            {
                return(suite);
            }
            else
            {
                var ts = new TestSuite("");
                Console.Error.WriteLine(ts.FullName);
                foreach (var i in AssemblyLevel.Cast <NUnitTest> ())
                {
                    ts.Add(i);
                }
                return(ts);
            }
        }
Exemplo n.º 3
0
        public Card(Suites suites, Values values)
        {
            Suite = suites;
            Value = values;

            switch (suites)
            {
            case Suites.Hearts:
                Symbol = "♥";
                Color  = ConsoleColor.Red;
                break;

            case Suites.Diamond:
                Symbol = "♦";
                Color  = ConsoleColor.Red;
                break;

            case Suites.Clubs:
                Symbol = "♣";
                Color  = ConsoleColor.White;
                break;

            case Suites.Spades:
                Symbol = "♠";
                Color  = ConsoleColor.White;
                break;

            default:
                break;
            }
        }
Exemplo n.º 4
0
        public Card(int _value, Suites _suite)
        {
            Value  = _value;
            Suite  = _suite;
            FaceUp = false;

            String st = Value.ToString();

            switch (Suite)
            {
            case Suites.Hearts: st += "H"; break;

            case Suites.Clubs: st += "C"; break;

            case Suites.Diamonds: st += "D"; break;

            case Suites.Spades: st += "S"; break;
            }


            SetImages(st);


            SuiteString = Suite.ToString();
            ValueString = Value.ToString();
        }
Exemplo n.º 5
0
        //private static void TestSorts()
        //{
        //    var dealer = new CardDealer();


        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();
        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();
        //        deck.Sort();
        //    }

        //    Console.WriteLine("list.sort: " + Card.ComparisonCount);
        //    Card.ResetComparisonCount();


        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();
        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();
        //        deck = deck.OrderBy(_ => _).ToList();
        //    }

        //    Console.WriteLine("linq: " + Card.ComparisonCount);
        //    Card.ResetComparisonCount();

        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();
        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();
        //        Sorts.InsertionSort(deck);
        //    }

        //    Console.WriteLine("insertion: " + Card.ComparisonCount);

        //    Card.ResetComparisonCount();

        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();
        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();

        //        Sorts.BubleSort(deck);
        //    }

        //    Console.WriteLine("bubble: " + Card.ComparisonCount);


        //    Card.ResetComparisonCount();

        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();
        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();

        //        Sorts.ShakeSort(deck);
        //    }

        //    Console.WriteLine("shake: " + Card.ComparisonCount);
        //    Card.ResetComparisonCount();

        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();

        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();

        //        deck = Sorts.MergeSort(deck);
        //    }

        //    Console.WriteLine("merge: " + Card.ComparisonCount);
        //    Card.ResetComparisonCount();

        //    for (var i = 0; i < 1000; i++)
        //    {
        //        dealer.Shuffle();

        //        var deck = dealer.Deal(52).ToList();
        //        deck = deck.Concat(deck).ToList();

        //        deck = Sorts.QuickSort(deck);
        //    }

        //    Console.WriteLine("quick: " + Card.ComparisonCount);

        //}

        private static void PrintSyracuse(ulong v)
        {
            for (ulong i = 1; i < 100; i++)
            {
                Console.WriteLine($"{i} => {Suites.MaxSyracuseAltitude(i)} {Suites.SyracuseFlightDuration(i)}");
            }
        }
Exemplo n.º 6
0
        public Card(int value, Suites suite, Spot startSpot = null, bool isMarker = false)
        {
            _value   = value;
            _suite   = suite;
            _spot    = startSpot;
            IsMarker = isMarker;

            GetFrontImage();
            GetBackImage();
        }
Exemplo n.º 7
0
        private static void PrintFibo()
        {
            foreach (var n in Suites.Fibo().Where(i => i % 2 == 0).TakeWhile(i => i < 1000000000000000))
            {
                Console.WriteLine(n);
            }
            Console.WriteLine();

            Console.WriteLine(Suites.Fibo().TakeWhile(i => i < 1000000000000000).Count(i => i % 2 == 0));
        }
Exemplo n.º 8
0
        public Card HighestOfSuit(Suites suit)
        {
            var allSuitMatches = Cards.FindAll(c => c.Suit == suit);

            if (allSuitMatches.Count == 0)
            {
                return(null);
            }
            allSuitMatches.Sort((first, second) => second.Value.CompareTo(first.Value)); //second to first is decending order
            return(allSuitMatches[0]);
        }
Exemplo n.º 9
0
 void AddTest(TestSuite suite)
 {
     Suites.Add(suite.FullName ?? suite.Name, suite);
     foreach (ITest test in suite.Tests)
     {
         TestSuite ts = (test as TestSuite);
         if (ts != null)
         {
             AddTest(ts);
         }
     }
 }
Exemplo n.º 10
0
        public static string[] sort(string[] names)
        {
            //short name first, unless it is fully contained in a longer name
            string[] _names = (string[])names.Clone();
            System.Array.Sort(_names, comparer);
            Suites suites = new Suites();

            for (int i = _names.Length - 1; i >= 0; i--)
            {
                suites.add(_names[i]);
            }
            return(suites.toArray());
        }
Exemplo n.º 11
0
        public Deck()
        {
            deck = new List <Card>();

            for (int i = 0; i < 4; i++)
            {
                Suites suites = (Suites)i;

                for (int j = 0; j < 13; j++)
                {
                    Values value   = (Values)j;
                    Card   newCard = new Card(suites, value);
                    deck.Add(newCard);
                }
            }
        }
Exemplo n.º 12
0
        private bool BustCheck()
        {
            if (Field.Count == 0)
            {
                return(false);
            }
            Suites      lastSuit      = Field[Field.Count - 1].Suit;
            List <Card> matchingCards = Field.FindAll(a => a.Suit == lastSuit);

            if (matchingCards.Count > 1)
            {
                processBust();
                return(true);
            }
            return(false);
        }
Exemplo n.º 13
0
        private ObservableCollection <SuiteModel> GetSuites()
        {
            var list = controller.SuiteList("transacao");

            foreach (var item in list)
            {
                try
                {
                    Suites.Add(new SuiteModel(item));
                }
                catch {
                    var n = item.Nome;
                }

                Suites = Suites;
            }
            return(Suites);
        }
Exemplo n.º 14
0
        void AddTest(TestSuite suite, AssemblyName assemblyName)
        {
            string name = suite.FullName ?? suite.Name;

            if (Suites.ContainsKey(name))
            {
                string newname = $"{assemblyName.Name}!{name}";
                Log.Warn(TAG, $"Duplicate test suite '{name}', assigning new name '{newname}'");
                name = newname;
            }

            Suites.Add(name, suite);
            foreach (ITest test in suite.Tests)
            {
                TestSuite ts = (test as TestSuite);
                if (ts != null)
                {
                    AddTest(ts, assemblyName);
                }
            }
        }
 public Card(int Value, Suites Suite)
 {
     this.Value = Value;
     this.Suite = Suite;
 }
Exemplo n.º 16
0
        public int CardsInSuit(Suites suit)
        {
            var allSuitMatches = Cards.FindAll(c => c.Suit == suit);

            return(allSuitMatches.Count);
        }
Exemplo n.º 17
0
 public Card(Ranks vRank, Suites vSuit)
 {
     ID = ((int)vRank % RankCount) + (((int)vSuit % SuitCount) * RankCount);
 }
Exemplo n.º 18
0
 public Card()
 {
     m_value = Values.UNINITIALIZED;
     m_suite = Suites.UNINITIALIZED;
 }
Exemplo n.º 19
0
 public Card(Suites suite, int value)
 {
     Suite = suite;
     Value = value;
 }
Exemplo n.º 20
0
 public Card(Suites suite, Ranks rank)
 {
     this.suite = suite;
     this.rank  = rank;
 }
Exemplo n.º 21
0
        //constructor for dealing random cards

        public Card(int Rank, Suites suite)
        {
            this.Rank  = Rank;
            this.Suite = suite;
        }
Exemplo n.º 22
0
 /// <summary>
 /// This constructor makes sure a card has a number and a suite
 /// </summary>
 /// <param name="cardNumber">The enum of a number</param>
 /// <param name="suite">The enum of a suite</param>
 public Card(Number cardNumber, Suites suite)
 {
     CardNumber = cardNumber;
     CardSuite  = suite;
 }
Exemplo n.º 23
0
 public Card(string input)
 {
     _suite        = Suites.FromString(input[1].ToString());
     _numericValue = NumericValues.FromString(input[0].ToString());
 }
Exemplo n.º 24
0
 public Card(Values value, Suites suite)
 {
     m_value = value;
     m_suite = suite;
 }
Exemplo n.º 25
0
 public void SetSuite(Suites suite)
 {
     m_suite = suite;
 }
Exemplo n.º 26
0
 public Card(Suites suite, Ranks rank)
 {
     Suite = suite;
     Value = rank;
 }
Exemplo n.º 27
0
 public Card(Suites suite, Ranks rank, CardStates state)
 {
     this.suite = suite;
     this.rank  = rank;
     this.state = state;
 }
Exemplo n.º 28
0
 public Card(Suites suite, Ranks rank)
 {
     Suite    = suite;
     Value    = rank;
     Combined = $"{rank}{suite}";
 }