資源簡介
編寫一個模擬人工洗牌的程序,將洗好的牌分別發給四個人。
使用結構card 來描述一張牌,用隨機方法來模擬人工洗牌的過程,最后將洗好的52張牌順序分別發給四個人。
設計要求:
1)要求使用java類包中的Math.Random()方法進行隨機處理。
2)要求在dos控制臺窗口中顯示每個人手上的撲克牌
3)要求將每個人手上的13張牌按照四種花色,從小到大排列整齊后顯示出來。
*4)可以設計成圖形用戶界面,通過按鈕進行洗牌、發牌的動作,并按上面的要求顯示東西南北四個人手上的牌型。
此代碼按照要求做好,并有注釋,方便根據個人需要修改。
代碼片段和文件信息
package?demo;
import?java.awt.event.MouseEvent;
import?java.awt.event.MouseListener;
import?javax.swing.ImageIcon;
import?javax.swing.JLabel;
public?class?Card?extends?JLabel?implements?MouseListener{
Main?main;//Main類的引用
String?name;//圖片url名字
boolean?up;//是否正反面
public?Card(Main?mString?nameboolean?up){
this.main=m;
this.name=name;
this.up=up;
????if(this.up)
???? this.turnFront();
????else?{
this.turnRear();
}
this.setSize(71?96);
this.setVisible(true);
}
//正面
public?void?turnFront()?{
this.setIcon(new?ImageIcon(“images/“?+?name?+?“.gif“));
this.up?=?true;
}
//反面
public?void?turnRear()?{
this.setIcon(new?ImageIcon(“images/rear.jpg“));
this.up?=?false;
}
public?void?mouseEntered(MouseEvent?arg0)?{}
publ
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????388??2017-11-25?01:40??四人發牌洗牌程序\.classpath
?????文件?????????400??2018-04-08?22:23??四人發牌洗牌程序\.project
?????目錄???????????0??2017-12-05?22:42??四人發牌洗牌程序\.settings\
?????文件?????????629??2012-08-10?10:59??四人發牌洗牌程序\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2018-04-08?22:23??四人發牌洗牌程序\bin\
?????目錄???????????0??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\
?????文件????????1695??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Card.class
?????文件????????1136??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Common$1.class
?????文件????????3018??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Common.class
?????文件?????????570??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Main$1.class
?????文件?????????570??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Main$2.class
?????文件????????7177??2018-04-08?22:23??四人發牌洗牌程序\bin\demo\Main.class
?????目錄???????????0??2017-12-05?22:42??四人發牌洗牌程序\images\
?????文件?????????522??2011-11-03?14:01??四人發牌洗牌程序\images\1-1.gif
?????文件?????????618??2011-11-03?14:01??四人發牌洗牌程序\images\1-10.gif
?????文件????????1093??2011-11-03?14:01??四人發牌洗牌程序\images\1-11.gif
?????文件????????1177??2011-11-03?14:01??四人發牌洗牌程序\images\1-12.gif
?????文件????????1077??2011-11-03?14:01??四人發牌洗牌程序\images\1-13.gif
?????文件?????????474??2011-11-03?14:01??四人發牌洗牌程序\images\1-2.gif
?????文件?????????432??2011-11-03?14:01??四人發牌洗牌程序\images\1-3.gif
?????文件?????????463??2011-11-03?14:01??四人發牌洗牌程序\images\1-4.gif
?????文件?????????478??2011-11-03?14:01??四人發牌洗牌程序\images\1-5.gif
?????文件?????????508??2011-11-03?14:01??四人發牌洗牌程序\images\1-6.gif
?????文件?????????526??2011-11-03?14:01??四人發牌洗牌程序\images\1-7.gif
?????文件?????????562??2011-11-03?14:01??四人發牌洗牌程序\images\1-8.gif
?????文件?????????581??2011-11-03?14:01??四人發牌洗牌程序\images\1-9.gif
?????文件?????????410??2011-11-03?14:01??四人發牌洗牌程序\images\2-1.gif
?????文件?????????661??2011-11-03?14:01??四人發牌洗牌程序\images\2-10.gif
?????文件????????1182??2011-11-03?14:01??四人發牌洗牌程序\images\2-11.gif
?????文件????????1226??2011-11-03?14:01??四人發牌洗牌程序\images\2-12.gif
?????文件????????1192??2011-11-03?14:01??四人發牌洗牌程序\images\2-13.gif
............此處省略44個文件信息
評論
共有 條評論