亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? card.java

?? good project for programmer,,
?? JAVA
字號(hào):
package com.sillysoft.lux;import java.util.List;import java.util.ArrayList;/** The Card class provides a data structure for representing cards, as well as some methods for checking sets.*/public class Card{// The country code of the country that is on this card:int countryCode;// The symbol on the card (we just assign the three different // pictures to be 0 for horses, 1 for cannons, 2 for men, and 3 // for wildcard (on which there will be a country code of -1):int symbol;public Card( int assocCode, int symbol )	{	this.symbol = symbol;	if ( symbol == 3 )		{		countryCode = -1;		}	else		{		countryCode = assocCode;		}	}/** Returns the country code associated with this card. It will return -1 if the card is wild. */public int getCode()	{	return countryCode;	}/** Returns the symbol on the card. Normal symbols are 0,1,2 while wildcards are 3.*/public int getSymbol()	{	return symbol;	}/** A test of whether these three cards are a cashable set. */public static boolean isASet( Card card1, Card card2, Card card3 )	{	if (card1 == null || card2 == null || card3 == null)		return false;	// Cycle through the cards and count the number of each symbol:	int symbolCount[] = new int[4];	symbolCount[ card1.getSymbol() ]++;	symbolCount[ card2.getSymbol() ]++;	symbolCount[ card3.getSymbol() ]++;	if ( symbolCount[0] + symbolCount[3] == 3 || symbolCount[1] + symbolCount[3] == 3 || symbolCount[2] + symbolCount[3] == 3 )		return true;	if ( ( Math.min( symbolCount[0], 1 ) + Math.min( symbolCount[1], 1 ) + Math.min( symbolCount[2], 1 ) + symbolCount[3] ) > 2 )		return true;	// Otherwise, they have no set:	return false;	}/** A test of whether the array of cards contains at least one cashable set. */public static boolean containsASet( Card[] cards )	{	if (cards == null || cards.length < 3)		return false;	// A player has a match if he has either three cards with the same symbol, or one of each symbol.	// Wildcard's symbol is 3, it can be anything.	// Cycle through the cards and count the number of each symbol:	int symbolCount[] = new int[4];	for (int i = 0; i < cards.length; i++)		{		symbolCount[ cards[i].getSymbol() ]++;		}	// See if they have three of a kind (3 counts for anything):	for (int i = 0; i < 3; i++)		{		if ( symbolCount[i] + symbolCount[3] > 2 )			{			return true;			}		}	// Now see if they have one of each (3 counts for anything):	if ( ( Math.min( symbolCount[0], 1 ) + Math.min( symbolCount[1], 1 ) + Math.min( symbolCount[2], 1 ) + symbolCount[3] ) > 2 )		{		return true;		}	// Otherwise, we have no set:	return false;	}/** This returns a size-3 Card array, containing a random set from amongst the given array.*The return value is undefined if there is no set. Use containsASet() to check first. */public static Card[] getRandomSet( Card[] cards )	{	Card[] toReturn = new Card[3];	// Cycle through the cards and count the number of each symbol:	int symbolCount[] = new int[4];	for (int i = 0; i < cards.length; i++)		{		symbolCount[ cards[i].getSymbol() ]++;		}	// See if they have three of a kind (3 counts for anything):	for (int i = 0; i < 3; i++)		{		if ( symbolCount[i] + symbolCount[3] > 2 )			{			int setCounter = 0;			// Then they have a set with symbol i, let's get it:			for (int j = 0; setCounter != 3 && j < cards.length; j++)				{				if ( cards[j].getSymbol() == i || cards[j].getSymbol() == 3 )					{					toReturn[ setCounter ] = cards[j];					setCounter++;					}				}			return toReturn;			}		}	// OK, so they don't have three symbols of a kind. that means that they must have one of each.	// Let's find them:	for (int j = 0; j < cards.length; j++)		{		if ( toReturn[0] == null && cards[j].getSymbol() == 0 )			{			toReturn[0] = cards[j];			}		else if ( toReturn[1] == null && cards[j].getSymbol() == 1 )			{			toReturn[1] = cards[j];			}		else if ( toReturn[2] == null && cards[j].getSymbol() == 2 )			{			toReturn[2] = cards[j];			}		else if ( cards[j].getSymbol() == 3 )			{			if ( symbolCount[0] == 0 && toReturn[0] == null )				{				toReturn[0] = cards[j];				}			else if ( symbolCount[1] == 0 && toReturn[1] == null )				{				toReturn[1] = cards[j];				}			else if ( symbolCount[2] == 0 && toReturn[2] == null )				{				toReturn[2] = cards[j];				}			}		}	return toReturn;	}/** This returns a size-3 Card array, containing a set from amongst the given array that uses as many cards owned by <i>player</i> as possible. Returns null if no sets are found.	*/public static Card[] getBestSet( Card[] cards, int player, Country[] countries )    {		// First look for a set using non wildcards:	List noWildList = new ArrayList();	List wildList = new ArrayList();	for (int i = 0; i < cards.length; i++)		{		if (cards[i].getSymbol() != 3)			noWildList.add(cards[i]);		else			wildList.add(cards[i]);		}	if (cards.length > noWildList.size())		{		// Then there were some wildcards. Look for a set amongst the non-wildcards:		Card[] noWildCards = new Card[noWildList.size()];		for (int i = 0; i < noWildList.size(); i++)			noWildCards[i] = (Card) noWildList.get(i);					Card[] bestNoWildSet = Card.getBestSet(noWildCards, player, countries);		if (bestNoWildSet != null)			{			// We found a set using no wildcards, return it:			return bestNoWildSet;			}					// No set was found using none of our wildcards. try with only one if we have multiple wildcards:		if (cards.length > noWildList.size() + 1)			{			Card[] oneWildCardList = new Card[noWildList.size() + 1];			for (int i = 0; i < noWildList.size(); i++)				oneWildCardList[i] = (Card) noWildList.get(i);			oneWildCardList[oneWildCardList.length-1] = (Card) wildList.get(0);						Card[] bestOneWildSet = Card.getBestSet(oneWildCardList, player, countries);			if (bestOneWildSet != null)				{				// We found a set using no wildcards, return it:				return bestOneWildSet;				}						}		}			// our attempts at finding a set with no wildcards have failed (or we have no wildcards).			    // populate an array with the ownercodes of the cards    int[] owners = new int[cards.length];    int owned = 0;    for (int i = 0; i < cards.length; i++)        {		if (cards[i].getCode() == -1)			owners[i] = -1;		else			{			owners[i] = countries[cards[i].getCode()].getOwner();			if (owners[i] == player)				owned++;			}        }    // start by getting an array with all the owned cards    Card[] ownedCards = new Card[owned];    int count = 0;        for (int i = 0; i < cards.length; i++)        {        if (owners[i] == player)            {            ownedCards[count] = cards[i];            count++;            }        }    if (owned > 2)        {        if (Card.containsASet( ownedCards ))            {            return Card.getRandomSet( ownedCards );            }        }    // OK, they have no sets made up of three of their cards.    // look for sets with two now    if (owned > 1)        {        Card[] ownedPlus = new Card[owned+1];        for (int i = 0; i < owned; i++)            ownedPlus[i] = ownedCards[i];         // now loop over all the non-owned cards looking for a set using only one of them        for (int c = 0; c < cards.length; c++)            {            if (owners[c] != player)                {                ownedPlus[owned] = cards[c];                if (Card.containsASet( ownedPlus ))                    {                    return Card.getRandomSet( ownedPlus );                    }                }            }        }    // ok, there is no set using two of the player's cards    if (owned > 0)        {        Card[] ownedPlusPlus = new Card[owned+2];        for (int i = 0; i < owned; i++)            ownedPlusPlus[i] = ownedCards[i];         for (int c = 0; c < cards.length; c++)        for (int d = 0; d < cards.length; d++)            {            if (owners[c] != player && owners[d] != player && c != d)                {                ownedPlusPlus[owned] = cards[c];                ownedPlusPlus[owned+1] = cards[d];                if (Card.containsASet( ownedPlusPlus ))                    {                    return Card.getRandomSet( ownedPlusPlus );                    }                }            }        }	// Check for any set at all	if (Card.containsASet(cards))		return Card.getRandomSet(cards);    return null;    }/** The way this method is implemented all wildcards are equal to each other!!! */public boolean equals(Object other)	{	if (other instanceof Card)		{		Card card = (Card) other;		return (card.countryCode == this.countryCode && card.symbol == this.symbol);		}	return false;	}/** Gives a String representation of the card.*/public String toString()	{	return "<Card symbol=\""+symbol+"\" country=\""+countryCode+"\">";	}}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美tickling挠脚心丨vk| 一区二区三区国产精品| 日韩亚洲欧美高清| 精品日韩一区二区三区| 日韩欧美视频一区| 久久这里都是精品| 国产精品剧情在线亚洲| 一区二区三区在线免费观看 | 韩国v欧美v日本v亚洲v| 美女任你摸久久| 国产麻豆视频一区二区| av电影在线观看一区| 欧美性生活大片视频| 日韩一二三区视频| |精品福利一区二区三区| 日韩av一区二| 色综合天天狠狠| 久久综合久久鬼色中文字| 亚洲激情中文1区| 国产一区二区三区不卡在线观看 | 亚洲一二三级电影| 国产精品一区二区视频| 欧美日韩亚洲高清一区二区| 国产色产综合产在线视频| 亚洲国产精品久久久久婷婷884| 国产成人精品午夜视频免费| 欧美日韩久久不卡| 国产精品毛片久久久久久久| 91免费在线播放| 日韩欧美一区二区久久婷婷| 亚洲欧美乱综合| 粉嫩13p一区二区三区| 欧美一区二区在线观看| 亚洲综合色视频| 丁香婷婷综合色啪| 日韩免费电影网站| 亚洲电影在线播放| 色综合久久天天| 欧美国产视频在线| 激情深爱一区二区| 欧美精品xxxxbbbb| 亚洲曰韩产成在线| 91一区二区在线| 中文字幕 久热精品 视频在线| 蜜臂av日日欢夜夜爽一区| 欧美日韩国产精选| 亚洲裸体xxx| 成人禁用看黄a在线| 久久久国产精品麻豆| 免费在线观看一区二区三区| 欧美色爱综合网| 亚洲九九爱视频| 成人av网站在线| 国产欧美一区视频| 国产成人啪午夜精品网站男同| 日韩欧美久久久| 秋霞成人午夜伦在线观看| 欧美久久久久免费| 亚洲r级在线视频| 欧美日韩国产首页| 亚洲福利电影网| 欧美色图在线观看| 亚洲永久免费视频| 欧美色视频在线| 亚洲成人免费看| 欧美日韩大陆在线| 中文字幕一区二区三区四区 | 91精品国产综合久久小美女| 亚洲一区精品在线| 色噜噜偷拍精品综合在线| 亚洲人成亚洲人成在线观看图片 | 亚洲日本乱码在线观看| av电影在线观看一区| 综合久久一区二区三区| 99视频超级精品| 亚洲欧美国产三级| 在线观看精品一区| 天天爽夜夜爽夜夜爽精品视频| 欧美精三区欧美精三区| 美女一区二区三区| 久久―日本道色综合久久| 国产酒店精品激情| 国产精品国产三级国产普通话99 | 亚洲一区av在线| 欧美天堂一区二区三区| 午夜精品久久久久久久蜜桃app| 在线成人高清不卡| 久久99久久久久| 欧美韩日一区二区三区| 99国产精品国产精品毛片| 亚洲一本大道在线| 日韩一二三四区| 国产精品18久久久久久久久| 亚洲欧洲精品天堂一级| 色爱区综合激月婷婷| 五月婷婷激情综合网| 日韩欧美一级二级三级久久久| 国模套图日韩精品一区二区| 国产女主播视频一区二区| 色系网站成人免费| 日韩精品欧美精品| 久久久久久毛片| 色视频欧美一区二区三区| 丝袜美腿亚洲一区| 久久久久久免费毛片精品| 一本一道久久a久久精品综合蜜臀| 天堂一区二区在线| 久久久久久久久一| 色呦呦网站一区| 捆绑调教一区二区三区| 成人免费一区二区三区视频| 91麻豆精品国产91久久久久久| 国产精品一二三| 亚洲精品国产a久久久久久| 欧美电影免费观看高清完整版在线 | 91网址在线看| 免播放器亚洲一区| 国产精品丝袜一区| 6080午夜不卡| 99r国产精品| 老司机免费视频一区二区三区| 亚洲特级片在线| 精品国产免费一区二区三区香蕉| 99久久er热在这里只有精品66| 奇米777欧美一区二区| 亚洲欧洲99久久| 欧美v国产在线一区二区三区| 91在线视频播放| 激情图区综合网| 亚洲福利一二三区| 国产精品传媒入口麻豆| 欧美成人福利视频| 欧洲一区二区三区免费视频| 国产在线视视频有精品| 亚洲国产日产av| 亚洲国产精品传媒在线观看| 91精品国产色综合久久| 91首页免费视频| 国产精品夜夜嗨| 日本不卡一区二区| 一区二区三区在线免费视频| 国产欧美一区视频| 日韩精品一区二区三区视频播放| 在线观看国产日韩| jizz一区二区| 国产精品18久久久久久久久| 免费成人美女在线观看.| 一区二区成人在线视频| 欧美激情综合在线| 欧美tickle裸体挠脚心vk| 精品视频在线免费看| 99精品国产视频| 国产精品一区二区男女羞羞无遮挡 | 色婷婷综合视频在线观看| 国产精品一色哟哟哟| 美女视频黄久久| 日韩高清不卡一区二区三区| 亚洲永久免费视频| 亚洲你懂的在线视频| 中文乱码免费一区二区| 精品国产sm最大网站| 欧美一区二区三区精品| 欧美亚洲免费在线一区| 色综合天天狠狠| 91麻豆福利精品推荐| 不卡一区二区在线| 成人免费毛片嘿嘿连载视频| 国产福利精品一区| 国产一区二区三区黄视频| 久草热8精品视频在线观看| 肉色丝袜一区二区| 亚洲成人免费电影| 亚洲成av人影院| 亚洲成av人片观看| 亚洲va天堂va国产va久| 五月婷婷欧美视频| 丝袜美腿高跟呻吟高潮一区| 天堂av在线一区| 日韩电影一区二区三区四区| 日韩av在线免费观看不卡| 五月天国产精品| 日韩国产一区二| 麻豆免费看一区二区三区| 精品一区二区三区免费| 国产精品一品视频| 大陆成人av片| 99在线热播精品免费| 色94色欧美sute亚洲线路一久| 色婷婷综合五月| 欧美日韩亚洲综合在线| 欧美一级精品在线| 精品人在线二区三区| 久久精品在线观看| 国产精品国产自产拍高清av| 亚洲欧美激情在线| 亚洲无线码一区二区三区| 日本不卡在线视频| 国产一区二区女| 成人免费毛片aaaaa**| 色婷婷久久久综合中文字幕 |