Esempio n. 1
0
    static void Main()
    {
        Array suits = Enum.GetValues(typeof(Suit));

        int []            nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
        PlayingCard []    deck = new PlayingCard [suits.Length * nums.Length + 2];
        int               i    = 0; // index for deck
        AFs <PlayingCard> afs  = new AFs <PlayingCard>();

        // deck の中身を詰める。
        foreach (Suit s in suits)
        {
            foreach (int n in nums)
            {
                deck[i] = new NormalCard(s, n);
                i++;
            }
        }
        deck[i]     = new JokerCard("!");
        deck[i + 1] = new JokerCard("?");
        // 遊ぶ。
        Console.WriteLine(afs.to_s(deck));
        afs.shuffle(deck);
        Console.WriteLine(afs.to_s(deck));
    }
Esempio n. 2
0
        public void AllCardShouldHaveAValue()
        {
            var sut = new NormalCard(Suit.Clubs, CardValues.Ace);

            Assert.Equal(CardValues.Ace, sut.Value);
            var jSut = new JokerCard();

            Assert.Equal(CardValues.Joker, jSut.Value);
        }
Esempio n. 3
0
        public void AllCardShouldHaveASuit()
        {
            var sut = new NormalCard(Suit.Clubs, CardValues.Ace);

            Assert.Equal(Suit.Clubs, sut.Suit);
            var jSut = new JokerCard();

            Assert.Equal(Suit.None, jSut.Suit);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            ISample sample1 = new Sample1();

            sample1.SayHello("小明");


            ISample sample2 = new Sample2();

            sample2.SayHello("Mike");


            ISample sample3 = new Sample3();

            sample3.SayHello("山本桑");


            Console.WriteLine("==== new 关键字 测试 ===");

            AbstractSample sample3a = new Sample3();

            sample3a.SayHello("山本桑");
            sample3a.SayEnd();

            Sample3 sample3b = new Sample3();

            sample3b.SayHello("山本桑");
            sample3b.SayEnd();



            Console.WriteLine("==== override 与 new 的区别 ===");


            Console.WriteLine("卡=普通卡!");
            Card card1 = new NormalCard();

            card1.LineUp();
            card1.TakeMoney();

            Console.WriteLine("卡=金卡!");
            Card card2 = new GoldCard();

            card2.LineUp();
            card2.TakeMoney();

            Console.WriteLine("金卡=金卡!");
            GoldCard card3 = new GoldCard();

            card3.LineUp();
            card3.TakeMoney();


            Console.ReadLine();
        }
Esempio n. 5
0
 public NormalCard RemoveCard(NormalCard card)
 {
     if (card == null)
     {
         return(null);
     }
     if (m_Cards.Remove(card) == false)
     {
         return(null);
     }
     return(card);
 }
Esempio n. 6
0
 static void Main()
 {
     Array suits          = Enum.GetValues(typeof(Suit));
     int [] nums          = { 1,2,3,4,5,6,7,8,9,10,11,12,13 };
     PlayingCard [] deck  = new PlayingCard [ suits.Length * nums.Length + 2 ];
     int i                = 0; // index for deck
     AFs<PlayingCard> afs = new AFs<PlayingCard>();
     // deck の中身を詰める。
     foreach(Suit s in suits) {
       foreach(int n in nums) {
     deck[i] = new NormalCard(s,n);
     i++;
       }
     }
     deck[i  ] = new JokerCard("!");
     deck[i+1] = new JokerCard("?");
     // 遊ぶ。
     Console.WriteLine( afs.to_s(deck) );
     afs.shuffle(deck);
     Console.WriteLine( afs.to_s(deck) );
 }
Esempio n. 7
0
 public void AddCard(NormalCard card)
 {
     m_Cards.Add(card);
 }
Esempio n. 8
0
 public void Add(NormalCard card)
 {
     Cards.Add(card);
 }
Esempio n. 9
0
    /*
     * public List<NormalCard> GetCards(int cardId)
     * {
     *  List<NormalCard> result = new List<NormalCard>();
     *  for (int i = 0; i < Cards.Count; i++)
     *  {
     *      if (Cards[i].CardId == cardId)
     *          result.Add(Cards[i]);
     *  }
     *  return result;
     * }
     * public List<NormalCard> GetCards()
     * {
     *  List<NormalCard> result = new List<NormalCard>();
     *  for (int i = 0; i < Cards.Count; i++)
     *  {
     *      result.Add(Cards[i]);
     *  }
     *  return result;
     * }
     */
    public void Add(int cardId)
    {
        NormalCard card = new NormalCard(cardId);

        Add(card);
    }
Esempio n. 10
0
        public void AnNormalCardShouldHaveNonDefaultConstructor()
        {
            var sut = new NormalCard(Suit.Clubs, CardValues.Ace);

            Assert.NotNull(sut);
        }