Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 找不到适合GameDetails(int,int)构造函数GameDetails的构造函数。GameDetails()不适用_Java - Fatal编程技术网

Java 找不到适合GameDetails(int,int)构造函数GameDetails的构造函数。GameDetails()不适用

Java 找不到适合GameDetails(int,int)构造函数GameDetails的构造函数。GameDetails()不适用,java,Java,您好,我对Netbeans还是新手,对StackoverFlow和一般的编码都是全新的,我需要完成SpaceInvaders游戏的创建,我已经达到了一个惊人的高度。对于我的无参数构造函数,我遵循了我在前几周使用的方法,但没有效果。我理解大多数持这种观点的人可能会觉得这很容易,但我感谢任何帮助 package model; import dao.GameDetailsDAO; import java.io.Serializable; import java.sql.SQLException;

您好,我对Netbeans还是新手,对StackoverFlow和一般的编码都是全新的,我需要完成SpaceInvaders游戏的创建,我已经达到了一个惊人的高度。对于我的无参数构造函数,我遵循了我在前几周使用的方法,但没有效果。我理解大多数持这种观点的人可能会觉得这很容易,但我感谢任何帮助

package model;

import dao.GameDetailsDAO;
import java.io.Serializable;
import java.sql.SQLException;

/**
 * <p>
 * The details for one game, including the user playing, the game settings the scoring (shots fired, ships destroyed,
 * score and previous high score)
 * </p>
 * <p>
 * Company: TAFE SA</p>
 *
 * @version 1.0
 */
public class GameDetails implements Serializable {

    //constants
    public static final int POINTS_GAINED_FOR_SHIP_DESTROYED = 100;
    public static final int POINTS_LOST_FOR_WASTED_SHOT = 50;

    //instance variables set at object creation time
    private UserDetails userDetails;
    private GameSettings gameSettings;

    //instance variables NOT set at object creation time but updated through setters as game is played.

    private int highScore;
    private int score;
    private int shipsDestroyed;
    private int shotsFired;
    private boolean newHighScore; //Indicates wether the highScore is a new one

    //only 2 constructors required
    /**
     * UserDetails
     *
     *
     * 
     */
    //no args constructor
       public GameDetails(){
        this(POINTS_GAINED_FOR_SHIP_DESTROYED , POINTS_LOST_FOR_WASTED_SHOT, new UserDetails(), new GameSettings());
    }



    //all args constructor
    public GameDetails(UserDetails userDetails, GameSettings gameSettings, int highScore, int score, int shipsDestroyed, int shotsFired, boolean newHighScore) throws Exception {
        this.userDetails = userDetails;
        this.gameSettings = gameSettings;
        this.highScore = highScore;
        this.score = score;
        this.shipsDestroyed = shipsDestroyed;
        this.shotsFired = shotsFired;
        this.newHighScore = newHighScore;


        resetTheScoringDetails();
    }
包模型;
导入dao.GameDetailsDAO;
导入java.io.Serializable;
导入java.sql.SQLException;
/**
*
*一个游戏的详细信息,包括用户玩游戏、游戏设置和得分(射击、船只摧毁、,
*分数和以前的高分)
*

* *公司:TAFE SA

* *@version 1.0 */ 公共类GameDetails实现可序列化{ //常数 公共静态最终整型点数为100; 公共静态最终积分\u损失\u浪费\u投篮=50; //在对象创建时设置的实例变量 私人用户详细信息用户详细信息; 私人游戏设置游戏设置; //实例变量不是在对象创建时设置的,而是在玩游戏时通过setter更新的。 私人int高分; 个人智力得分; 私人国际船舶展; 私人内部拍摄; private boolean newHighScore;//指示highScore是否为新的 //只需要2名施工人员 /** *用户详细信息 * * * */ //无参数构造函数 公开游戏详情(){ 这(获得的点数、被摧毁的点数、被浪费的点数、新的用户详细信息()、新的游戏设置()); } //所有参数构造函数 公共游戏详细信息(UserDetails UserDetails、GameSettings GameSettings、int highScore、int score、int shipsDestroyed、int shotsFired、boolean newHighScore)引发异常{ this.userDetails=userDetails; this.gameSettings=游戏设置; this.highScore=高分; 这个分数=分数; this.shipsDestroyed=shipsDestroyed; this.shotsFired=shotsFired; this.newHighScore=newHighScore; 重置CorringDetails(); }
找不到适合GameDetails(int,int)构造函数GameDetails的构造函数。GameDetails()不适用

您没有一个用于
GameDetails
的构造函数,它只接受2个
int
参数

你所拥有的是:

public GameDetails()
public GameDetails(UserDetails, GameSettings, int, int, int, int, boolean)

你要么需要编写一个新的构造函数-
publicgamedetails(int,int)
,要么添加/删除参数以匹配你现有的构造函数签名。

我不认为这是javascriptPost你的StackTracey你的构造函数类有不同的参数,在你没有显示的代码中,你有
新的GameDetails(I,j)
(其中,
i
j
是一些整数。您的
GameDetails
类——至少您显示的部分——似乎没有包含两个整数参数的构造函数。如果您想从两个整数构造
GameDetails
,您必须编写一个具有确切签名的构造函数:
public GameDetails(int i1,int i2)