|
本文分享下,一段可模拟扑克牌玩法的php代码,有需要的朋友参考下。
php 扑克牌代码,如下:
wxPython 2.8 Application Development Cookbook英文pdf版
查看详情
在今天的桌面应用世界上有大量的奖励,以便能够开发应用程序,可以运行在多个环境。目前,有一种跨平台框架可供选择的Python开发桌面应用程序屈指可数。 wxPython的就是这样的一个跨平台的GUI工具包的Python编程语言。它允许Python程序员创建一个完整的,功能强大的图形用户界面的程序,简单,方便。 wxPython的代码风格,改变了多年来不少,并得到更多Python的。例子,你会发现这本书是对不断更新,反映在风格上的变化。 本书提供最新的书,快速创建健壮的,可靠,可重复使用的wxPython应用
1
<?php
/***
*
* A simple class to cut a deck of cards
* @version CVS: $Id:$
* @since Class available since Release 1.0.0
* Example use
*
* $cards = new cards;
* echo $cards->cut();
* www: jbxue.com
*/
class cards{
/**
*
* Declare our deck variable
*
*/
private $deck;
/**
*
* Constructor.. duh!
*
*/
function __construct(){
/*** set the deck array variable ***/
$this->deck=$this->setDeck();
}
/**
*
* Function set Deck
*
* @access private
*
* @return array
*
*/
private function setDeck(){
return array("ah", "ac", "ad", "as",
"2h", "2c", "2d", "2s",
"3h", "3c", "3d", "3s",
"4h", "4c", "4d", "4s",
"5h", "5c", "5d", "5s",
"6h", "6c", "6d", "6s",
"7h", "7c", "7d", "7s",
"8h", "8c", "8d", "8s",
"9h", "9c", "9d", "9s",
"th", "tc", "td", "ts",
"jh", "jc", "jd", "js",
"qh", "qc", "qd", "qs",
"kh", "kc", "kd", "ks");
}
/**
*
* Function get Key get the array key
*
* @access private
*
* @return INT
*
*/
private function getKey(){
shuffle($this->deck);
return array_rand($this->deck);
}
/**
*
* @Function cut, get the value of the array key
*
* @access public
*
* @return string
*
*/
public function cut(){
return $this->deck[$this->getKey()];
}
} /*** end of class ***/
$cards = new cards;
echo $cards->cut();
?>登录后复制 |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号