public void AddCard(Kort kort, int num)
        {
            bool found = false;

            if (currentCards < maxCard)
            {
                for (int i = 0; i < currentCards; i++)
                {
                    if (kort == kortlek[i])
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    if (num < currentCards)
                    {
                        kortlek.Insert(num, kort);
                        currentCards++;
                    }
                    else
                    {
                        Console.WriteLine("Det gick inte");
                    }
                }
            }
            else
            {
                Console.WriteLine("kortleken är full, skål");
            }
        }
 public void Initialize()
 {
     currentCards = maxCard;
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 52 / 4; j++)
         {
             Kort nyttKort = new Kort(j, i);
             kortlek.Add(nyttKort);
         }
     }
 }
 public Kort RemoveByChoise(int num)
 {
     if (num < currentCards)
     {
         Kort temp = kortlek[num - 1];
         Console.WriteLine("Nu spelades " + kortlek[num - 1]);
         kortlek.RemoveAt(num - 1);
         currentCards--;
         return(temp);
     }
     return(null);
 }
 public Kort RemoveLastCard()
 {
     if (currentCards > 1)
     {
         Kort temp = kortlek[currentCards - 1];
         Console.WriteLine("Nu spelades " + kortlek[currentCards - 1]);
         kortlek.RemoveAt(currentCards - 1);
         currentCards--;
         return(temp);
     }
     return(null);
 }
        public void StörstKort()
        {
            Kort temp  = kortlek[0];
            Kort temp2 = kortlek[1];

            if (Convert.ToInt32(temp.valör) > Convert.ToInt32(temp2.valör))
            {
                Console.WriteLine("störts första\n" + temp + temp2);
            }
            else
            {
                Console.WriteLine("störts första\n" + temp2 + temp);
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            //string a = "hej";
            Kortlek     a      = new Kortlek();
            Kortlek     b      = new Kortlek();
            List <Kort> bordet = new List <Kort>();

            a.Initialize();
            Kort c = a.RemoveFirstCard();

            a.Empty();
            a.BlandaNy();
            Console.WriteLine(a);


            a.AddCard(c, 5);
            Console.WriteLine(a);


            Console.ReadLine();
        }