Пример #1
0
		public void TestAddCards( )
		{
			// Create a pile, location is irrelevant in this case:
			SuitPile suitPile = new SuitPile( new Point( 0, 0 ) );

			Card tenOfSpades = new Card( Suit.Spades, 10 );
			Card aceOfHearts = new Card( Suit.Hearts, 1 );
			Card twoOfSpades = new Card( Suit.Spades, 2 );
			Card twoOfHearts = new Card( Suit.Hearts, 2 );

			//Assert.AreEqual( suitPile.AddCard( tenOfSpades ), false, "SuitPile should only accept an ace as a first card" );
			//Assert.AreEqual( suitPile.AddCard( aceOfHearts ), true,  "SuitPile should accept an ace as a first card" );
			//Assert.AreEqual( suitPile.AddCard( twoOfSpades ), false, "SuitPile should only accept cards in ascending order" );
			//Assert.AreEqual( suitPile.AddCard( twoOfHearts ), true, "SuitPile should accept cards in ascending order and of same suit" );
		}
Пример #2
0
		protected void CreateSuitPiles( )
		{
			// Suit piles start in the 4th column, so we need space
			// for the left margin, and 3 cards before the first pile.
			int nStartLeft = MARGIN_IN_PIXELS + ( 3 * ( Card.WIDTH + MARGIN_IN_PIXELS ) );

			// 4 suits, so 4 iterations in the loop:
			for ( int i = 0; i < 4; i++ )
			{
				// The suit piles are located in the topmost row. So we only 
				// need to make room for the top margin at the top
				Point pt = new Point( nStartLeft + ( i * ( Card.WIDTH + MARGIN_IN_PIXELS ) ), MARGIN_IN_PIXELS );
				SuitPile suitPile = new SuitPile( pt );

				// Add this suit pile both to our list of suit piles,
				// as well as to the list of all piles:
				m_suitPiles.Add( suitPile );
				m_piles.Add( suitPile );
			}
		}