• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

Java入门第三季求助

我尝试这用记事本完成《Java入门第三季》的最终作业,调试了一下午才编译通过,又显示“找不到或无法加载主类”,求帮忙看一下,多谢了!
package game;public class Main{        public static void main (String [] args){                new Game();        }}package game;import java.util.Scanner;import java.util.Random;import java.util.List;import java.util.ArrayList;public class Game {        List cards;        Player playerA,playerB;        short a;        Card temporary;        Random random;        public Game(){                this.random = new Random();                this.cards = new ArrayList();                Scanner scanner = new Scanner(System.in);                System.out.println("please input first player's name");                this.playerA = new Player(scanner.next());                System.out.println("please input second player's name");                this.playerB = new Player(scanner.next());                System.out.println("loading");                //开始洗牌                for(short times = 0;times < 52;times ++){                        do{                                this.temporary = new Card((short)(random.nextInt(13)+1),(short)(random.nextInt(4)+1));                        }while(this.cards.contains(temporary));                                        }                System.out.println("please waite a minute");                //开始发牌                a = (short)random.nextInt(this.cards.size());                this.playerA.take(this.cards.get(a));                this.cards.remove(a);                a = (short)random.nextInt(this.cards.size());                this.playerB.take(this.cards.get(a));                this.cards.remove(a);                a = (short)random.nextInt(this.cards.size());                this.playerA.take(this.cards.get(a));                this.cards.remove(a);                a = (short)random.nextInt(this.cards.size());                this.playerB.take(this.cards.get(a));                this.cards.remove(a);                                //开始比较                System.out.println("fight");                if(this.playerA.show().compareTo(this.playerB.show()) > 0){                        System.out.println("Player:A Wins !");                }else {                        System.out.println("Player:B Wins !");                }                //游戏结束                System.out.println("Game Over !");        }        }package game;public class Card implements Comparable {        short number;        short shape;        public Card(short number,short shape){                this.number = number;                this.shape = shape;        }                public int compareTo(Card card){                if(this.number == card.number){                        return (new Integer(this.shape)).compareTo(new Integer(card.shape));                }else {                        return (new Integer(this.number)).compareTo(new Integer(card.number));                }        }                public boolean equals(Card card){                if (this.number == card.number & this.shape == card.shape){                        return true;                }else{                        return false;                }                                }}package game;import java.util.List;import java.util.ArrayList;import java.util.Collections;public class Player {        String name;        List cards;        public Player(String name){                this.name = name;                this.cards = new ArrayList();        }        public Card show (){                                Collections.sort(this.cards);                return this.cards.get(1);        }        public void take (Card card){                this.cards.add(card);        }}

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与1

如果你确定代码、逻辑都没问题建议重启 eclipse,今天遇到几次一切都没问题就是404的情况,重启 eclipse 就好了

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!