Suit flushSuit = playDeck.GetCard(hand * 5).suit;
-----》这句话可以看成Ch10CardLib.Card card = playDeck.GetCard(hand * 5);
Suit flushSuit = card.suit;GetCard返回Card,而suit是Card的属性
-----》这句话可以看成Ch10CardLib.Card card = playDeck.GetCard(hand * 5);
Suit flushSuit = card.suit;GetCard返回Card,而suit是Card的属性
解决方案 »
- 奇怪,以前好好的代码居然报错,请大侠找原因
- c# 画曲线
- c# windows应用程序中怎么实现保存输入框中的用户名,密码!
- 兩個時間相減得到多少秒
- 查询数据库问题
- 如何在c#中将dropdownlist设置成readonly?
- (散1000分)收集一下vs.net的优点来说服我自己,来吧,骗骗我也好!
- Net写的最大的Winfrom软件是什么?有没有象Office,Photoshop一样大的软件产品?Net做写这样的程序吗?
- 想把数据库的几个表分别分在一个DataSet中,非得要几个DataAdapter中?
- 关于MSCHART的问题,急,请高手帮忙
- 用过teechart的高手进来
- VS2005创建的WEB服务项目发布到IIS定义的一个虚拟目录中后,在IIS中浏览不了啊,各位大哥大姐帮帮偶哦!
using System;
using System.Collections.Generic;
using System.Text;
using Ch10CardLib;namespace Ch10CardClient
{
class Class1
{
static void Main(string[] args)
{
while (true)/*这不是死循环了吗?后面也没有什么可以退出循环的啊?*/
{
Deck playDeck = new Deck();
playDeck.Shuffle();
bool isFlush = false;
int flushHandIndex = 0;
for (int hand = 0; hand < 10; hand++)
{
isFlush = true;
Suit flushSuit = playDeck.GetCard(hand * 5).suit;/*这是什么意思,GetCard是playDeck的方法,那suit又是GetCard的什么?还有,GetCard中的参数,hand乘以5是个什么用意?*/
for (int card = 1; card < 5; card++)
{
if (playDeck.GetCard(hand * 5 + card).suit != flushSuit)
{
isFlush = false;
}
}
if (isFlush)
{
Console.WriteLine("Flush!");
for (int card = 0; card < 5; card++)
{
Console.WriteLine(playDeck.GetCard(flushHandIndex + card));/*flushHandIndex在本类中就出现两次,一次是这,另一次是上面,声明并赋值为0。那既然是0,有没有它都没有什么影响啊,干嘛还要多个变量出来?*/
}
}
else
{
Console.WriteLine("No flush.");
}
Console.ReadKey();
}
}
}
}
}
首先,我要说明一下,这不是我写的代码
然后,我说的那点,没有break
最后,我知道break可以退出循环,还有continue、return
经过你的解释,我再回头的仔细观察,明白了这一点
GetCard是Deck类的一个方法,该方法返回类型为Ch10CardLib.Card
而suit是Card类的一个公共、只读、枚举,字段。但,“还有,GetCard中的参数,hand乘以5是个什么用意?”
while (true)
<span style="color:#FF0000">
while (true)
</span>
readonly是不能赋值的
只能在两种情况下得到值
一是,在声明的时候
二是,通过构造函数(即,此题所用的方法)