当前位置: 首页 > news >正文

网站建设 策划学做网站的书籍

网站建设 策划,学做网站的书籍,链网,汽车网站设计我在这里有一个错误,我不知道它来自哪里.我在初学者的java课程是高中,所以我在这里还没有太多的经验.我有3个相互合并的程序.我有一个卡片类,可以创建一张扑克牌//********************************************************************// Card.java Author: Lewis and Loftus…我在这里有一个错误,我不知道它来自哪里.我在初学者的java课程是高中,所以我在这里还没有太多的经验.我有3个相互合并的程序.我有一个卡片类,可以创建一张扑克牌//********************************************************************// Card.java Author: Lewis and Loftus//// Solution to Programming Project 4.5//********************************************************************import java.util.*;public class Card{public final static int ACE 1;public final static int TWO 2;public final static int THREE 3;public final static int FOUR 4;public final static int FIVE 5;public final static int SIX 6;public final static int SEVEN 7;public final static int EIGHT 8;public final static int NINE 9;public final static int TEN 10;public final static int JACK 11;public final static int QUEEN 12;public final static int KING 13;public final static int CLUBS 1;public final static int DIAMONDS 2;public final static int HEARTS 3;public final static int SPADES 4;private final static int NUM_FACES 13;private final static int NUM_SUITS 4;private int face,suit;private String faceName,suitName;private int myInt1,myInt2;Random rand new Random();//-----------------------------------------------------------------// Creates a random card.//-----------------------------------------------------------------public Card (){face rand.nextInt(4) 1;setFaceName();suit rand.nextInt(13) 1;setSuitName();}//-----------------------------------------------------------------// Sets the string representation of the face using its stored// numeric value.//-----------------------------------------------------------------private void setFaceName(){switch (face){case 1:faceName Ace;break;case 2:faceName Two;break;case 3:faceName Three;break;case 4:faceName Four;break;case 5:faceName Five;break;case 6:faceName Six;break;case 7:faceName Seven;break;case 8:faceName Eight;break;case 9:faceName Nine;break;case 10:faceName Ten;break;case 11:faceName Jack;break;case 12:faceName Queen;break;case 13:faceName King;break;}}//-----------------------------------------------------------------// Sets the string representation of the suit using its stored// numeric value.//-----------------------------------------------------------------private void setSuitName(){switch (suit){case 1:suitName Clubs;break;case 2:suitName Diamonds;break;case 3:suitName Hearts;break;case 4:suitName Spades;break;}}//-----------------------------------------------------------------// Determines if this card is higher than the passed card. The// second parameter determines if aces should be considered high// (beats a King) or low (lowest of all faces). Uses the suit// if both cards have the same face.//-----------------------------------------------------------------public boolean isHigherThan (Card card2,boolean aceHigh){boolean result false;if (face card2.getFace()){if (suit card2.getSuit())result true;}else{if (aceHigh face ACE)result true;elseif (face card2.getFace())result true;}return result;}//-----------------------------------------------------------------// Determines if this card is higher than the passed card,// assuming that aces should be considered high.//-----------------------------------------------------------------public boolean isHigherThan (Card card2){return isHigherThan (card2,true);}//-----------------------------------------------------------------// Returns the face (numeric value) of this card.//-----------------------------------------------------------------public int getFace (){return face;}//-----------------------------------------------------------------// Returns the suit (numeric value) of this card.//-----------------------------------------------------------------public int getSuit (){return suit;}//-----------------------------------------------------------------// Returns the face (string value) of this card.//-----------------------------------------------------------------public String getFaceName (){return faceName;}//-----------------------------------------------------------------// Returns the suit (string value) of this card.//-----------------------------------------------------------------public String getSuitName (){return suitName;}//-----------------------------------------------------------------// Returns the string representation of this card,including// both face and suit.//-----------------------------------------------------------------public String toString (){return faceName of suitName;}}我有一张Deck Of cards文件可以创建52张卡片import java.util.*;public class DeckOfCards{private Card deckOfCards[];private int currentCardUsed;private final int NumberOfCards 52;private int nextCard;private Random rand;String myString All Cards have been dealt.;public DeckOfCards(){deckOfCards new Card[NumberOfCards];currentCardUsed 0;Random rand new Random();for(int index 0; index deckOfCards.length; index ){deckOfCards[index] new Card();}}public void shuffleCards(){currentCardUsed 0;for(int newCard 0; newCard deckOfCards.length; newCard ){int nextCard rand.nextInt(NumberOfCards);Card temporaryDeck deckOfCards[newCard];deckOfCards[newCard] deckOfCards[nextCard];deckOfCards[nextCard] temporaryDeck;}}public Card dealCard(){if(currentCardUsed deckOfCards.length){return deckOfCards[currentCardUsed ];}else{return null;}}}最后我有一个司机班public class DeckTester{public static void main(String [] args){DeckOfCards deck new DeckOfCards();deck.shuffleCards();System.out.println(deck.dealCard());System.out.println(deck.dealCard());System.out.println(deck.dealCard());System.out.println(deck.dealCard());System.out.println(deck.dealCard());System.out.println(deck.dealCard());}}他们都没有错误.但是当我运行驱动程序时,我得到了输出Exception in thread main java.lang.NullPointerExceptionat DeckOfCards.shuffleCards(DeckOfCards.java:39)at DeckTester.main(DeckTester.java:8)我试过在交易方法中改变Null无济于事.
http://www.pierceye.com/news/637472/

相关文章:

  • 凡科网的网站建设好用吗网站开发过程的数据交互
  • 郑州做商城网站公司开发微信小程序流程
  • 宝安电子厂做网站外包app开发多少钱
  • 箱包 东莞网站建设公司网站建设与设计制作
  • 网站如何做点击链接地址直播平台排行榜前十名
  • 万网域名指向网站wordpress 下载媒体库
  • 小店网站制作php做的网站首页是什么文件
  • i深建官方网站淮南网络营销哪家强
  • 网上网站怎么做织梦网站模块
  • 怎么新建自己的网站百度广告推广费用
  • 北京 科技网站建设上海短视频推广公司
  • 帮别人做网站哪里可以接单大型网站开发团队的美工需要什么工作经验和教育背景及薪酬
  • 网站开发工程师社交哔哩哔哩网页版入口2023在线观看
  • 凡客 网站设计wordpress也没
  • 深圳的网站建设公司排名电话外呼系统呼叫中心系统
  • 2022没封的网站免费的闵行区网站建设
  • 网站域名做入什么科目网络营销的主要内容是什么
  • 网站平面模板网站建设招标模板
  • 网站系统升级需要多久渐变网站
  • 网站建设数据库代码做煤的网站app
  • 做家电维修网站能接到单吗十大赚钱小程序
  • 手机网站表单页面制作小游戏网站审核怎么做
  • 浅谈高校门户网站建设的规范标准wordpress改变文章页宽度
  • 做网站必须得ipc支部网站建设
  • 受欢迎的医疗网站建设常德网站开发哪家好
  • 小区服务网站怎么做常州网站制作哪家好
  • 全国各大网站网站制度建设情况
  • 两学一做网站视频软文广告是什么意思
  • 网站等级保护如何做谷歌推广方案
  • 哪些网站做免费送东西的广告nas怎么做网站服务器