This site requires JavaScript, please enable it in your browser!
Greenfoot back
DerEchteBjarne
DerEchteBjarne wrote ...

2021/10/4

cannot be applied to given types

DerEchteBjarne DerEchteBjarne

2021/10/4

#
I get the Information: constructor Mensch in class Mensch cannot be applied to given types; requeired: java.lang.String,char,int,double,boolean found: no arguments reason: actual and formal argument lists differ in length Im sorry if it is a typical mistake because im new.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Mensch here.
 * 
 * @author (Bjarne Müller) 
 * @version (3)
 */
public class Mensch extends Actor
{
    //Atributsdeklaration
    public String name;
    public char geschlecht;
    public int alter;
    public double groesse;
    public boolean brillentraeger;
    /**
     * Konstruktor, der ein objekt der Klasse Mensch erzeugt.
     */
    public Mensch(String pName, char pGeschlecht, int pAlter, double pGroesse, boolean  pBrillentraeger )
    {
     name= pName;
     geschlecht= pGeschlecht;
     alter= pAlter;
     groesse=  pGroesse;
     brillentraeger= pBrillentraeger;
    }
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Lehrer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Lehrer extends Mensch
{
    //Atributsdeklaration
    private String kuerzel;
    private int faecherzahl;
    private boolean streng;
    private int anzahlSchueler;
    private boolean tutorOderKlassenlehrer;
    /**
     * Act - do whatever the Lehrer wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void setLehrer(String pKuerzel)
    {
        kuerzel= pKuerzel;
    }
    
    public String getKuerzel()
    {
        return kuerzel;
    }
    
    public void setFaecherzahl(int pFaecherzahl)
    {
        faecherzahl= pFaecherzahl;
    }
    
    public int getFaecherzahl()
    {
        return faecherzahl;
    }
    
    public void setStreng(boolean pStreng)
    {
        streng= pStreng;
    }
    
    public boolean getStreng()
    {
        return streng;
    }
    
    public void setAnzahlSchueler(int pAnzahlSchueler)
    {
        anzahlSchueler= pAnzahlSchueler;
    }
    
    public int getAnzahlSchueler()
    {
        return anzahlSchueler;
    }
    
    public void setTutorOderKlassenlehrer(boolean pTutorOderKlassenlehrer)
    {
        tutorOderKlassenlehrer= pTutorOderKlassenlehrer;
    }
    
    public boolean getTutorOderKlassenlehrer()
    {
        return tutorOderKlassenlehrer;
    }
    
    public String getName()
    {
        return name;
    }
    
    public char getGeschlecht()
    {
        return geschlecht;
    }
    
    public int getAlter()
    {
        return alter;
    }
    
    public double getGroesse()
    {
        return groesse;
    }
    
    public boolean getBrillentraeger()
    {
        return brillentraeger;
    }
}
danpost danpost

2021/10/5

#
DerEchteBjarne wrote...
constructor Mensch in class Mensch cannot be applied to given types; requeired: java.lang.String,char,int,double,boolean found: no arguments reason: actual and formal argument lists differ in length
Add to Lehrer class:
public Lehrer()
{
    super("", (char)0, 0, 0, false);
}
Or, add to Mensch class:
public Mensch()
{
}
However, be it known that a Lehrer object IS a Mensch object because of class hierarchy. If you intended the classes to create different type objects (not just a more defined similar type), then one should not subclass the other.
DerEchteBjarne DerEchteBjarne

2021/10/6

#
Thank u very much it worked :) <3 #NoHomo
You need to login to post a reply.