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<Card> cards;
	Player playerA,playerB;
	short a;
	Card temporary;
	Random random;
	public Game(){

		this.random = new Random();
		this.cards = new ArrayList<Card>();
		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 <Card>{
	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<Card> cards;
	public Player(String name){
		this.name = name;
		this.cards = new ArrayList<Card>();
	}
	public Card show (){
		
		Collections.sort(this.cards);
		return this.cards.get(1);
	}
	public void take (Card card){
		this.cards.add(card);
	}
}


神华内敛方能以柔克刚
浏览 1061回答 1
1回答

carolcoral

如果你确定代码、逻辑都没问题建议重启 eclipse,今天遇到几次一切都没问题就是404的情况,重启 eclipse 就好了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java