3 本我 2天前 69次点击
现在要用到之前创建的类库,它包含一个表示扑克牌的Card类和一个表示一副扑克牌的Deck类,这个Deck类是Card类的集合,且实现为一个简单数组。
先创建一个新类Cards
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 录音1
{
public class Cards:CollectionBase
{
public void Add(Card newCard)
{
List.Add(newCard);
}
public void Remove(Card oldCard)
{
List.Remove(oldCard);
}
public Card this[int cardIndex]
{
get
{ return (Card)List[cardIndex]; }
set
{ List[cardIndex] = value; }
}
public void CopyTo(Cards targetCards)
{
for (int i = 0i < this.Count; i++)
{
targetCards[i] = this[i];
}
}
public bool Contains(Card card) => InnerList.Contains(card);
}
}
我们能学嗨桑吗
你什么时候写程序啊?别在这里枯坐学语法了。