公开考试失败

潘卡伊

我的代码:

public class Film {
    private Darsteller hauptdarsteller;
    private String titel;
    private int erscheinungsjahr;
    private int fsk;
    private Genre genre;
    private Blyadflix portal;

    public Film(String _titel, int _erscheinungsjahr, int _fsk, Genre _genre) {
        this.titel = _titel;
        this.erscheinungsjahr = _erscheinungsjahr;
        this.fsk = _fsk;
        this.genre = _genre;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Film)) {
            return false;
        }
        Film f = (Film) o;
        return this.getErscheinungsjahr() == f.getErscheinungsjahr()
                && this.getHauptdarsteller() == f.getHauptdarsteller() && this.getTitel() == f.getTitel()
                && this.getFsk() == f.getFsk() && this.getGenre() == f.getGenre();
    }

    public Darsteller getHauptdarsteller() {
        return hauptdarsteller;
    }

    public void setHauptdarsteller(Darsteller hauptdarsteller) {
        this.hauptdarsteller = hauptdarsteller;
    }

    public String getTitel() {
        return titel;
    }

    public void setTitel(String titel) {
        this.titel = titel;
    }

    public int getErscheinungsjahr() {
        return erscheinungsjahr;
    }

    public void setErscheinungsjahr(int erscheinungsjahr) {
        this.erscheinungsjahr = erscheinungsjahr;
    }

    public int getFsk() {
        return fsk;
    }

    public void setFsk(int fsk) {
        this.fsk = fsk;
    }

    public Genre getGenre() {
        return genre;
    }

    public void setGenre(Genre genre) {
        this.genre = genre;
    }

    public Blyadflix getPortal() {
        return portal;
    }

    public void setPortal(Blyadflix portal) {
        this.portal = portal;
    }
}

PublicTests.java:编译错误

constructor Film in class Film cannot be applied to given types;f =
new Film("Ein Tag im Zoo", 2002, 18, Genre.DRAMA, d);             
required: String,int,int,Genre   found:
String,int,int,Genre,Darsteller   reason: actual and formal argument
lists differ in length

我该如何解决?

万事达

您正在尝试调用构造函数,Film(String, int, int, Genre, Darsteller)但您的类只有一个构造函数Film(String, int, int, Genre)您需要编写第二个构造函数,该构造函数还带有一个Darsteller对象:

public Film(String _titel, int _erscheinungsjahr, int _fsk, Genre _genre, Darsteller _hauptdarsteller) {
    this.titel = _titel;
    this.erscheinungsjahr = _erscheinungsjahr;
    this.fsk = _fsk;
    this.genre = _genre;
    this.hauptdarsteller = _hauptdarsteller;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章