⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pack.cs

📁 微软(Microsoft)出版社C井练习文件及解答
💻 CS
字号:
namespace Cards
{
	using System;
	using System.Collections;

	class Pack
	{
		public Pack()
		{
			for (int pips = PlayingCard.Ace; pips <= PlayingCard.King; ++pips)
			{
				Accept(new PlayingCard(Suit.Clubs, pips));
				Accept(new PlayingCard(Suit.Diamonds, pips));
				Accept(new PlayingCard(Suit.Hearts, pips));
				Accept(new PlayingCard(Suit.Spades, pips));
			}
		}

		public bool IsEmpty()
		{
			return cards.Count == 0;
		}

		public PlayingCard Deal()
		{
			if (cards.Count == 0)
			{
				throw new InvalidOperationException("can't deal from empty pack");
			}
			PlayingCard dealt = (PlayingCard)cards[0];
			cards.RemoveAt(0);
			return dealt;
		}

		public void Accept(PlayingCard card)
		{
			cards.Add(card);
		}

		public void Clear()
		{
			cards.Clear();
		}

		public void Shuffle()
		{
			// to do
		}

		private ArrayList cards = new ArrayList();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -