Language Families

Hi all,

I’m stuck on the Language Families project, I am trying to run my code through the terminal and keep getting the following error message. error: constructor Language in class Language cannot be applied to give types;

required: no arguments
found: String,int,String,String
reason: actual and formal argument lists differ in length.

I believe this error is telling me that I am not passing enough arguments through parameters (if my understanding is correct)? Having checked my code I’m not sure where I am going wrong. Could I get some help please (code below).

public class Language {

protected String name;
protected int numSpeakers;
protected String regionSpoken;
protected String wordOrder;

public Language(String langName, int speakers, String regions, String order){

this.name = langName;
this.numSpeakers = speakers;
this.regionSpoken = regions;
this.wordOrder = order;
}
public getInfo() {
System.out.println(this.name + " is spoken by "+ this.numSpeakers + " people mainly in "+ 
 this.regionSpoken + ".");
System.out.println("The language follows the word order: " + this.wordOrder);
}

public static void main(String[] args){
Language English = new Language("English", 555, "England", "subject-verb-object");
English.getInfo();
}
}

When I copied and pasted your code I was given a return error on the terminal side.
Look at “public getInfo()”

unless you already figured it out in which case…@.@

I am having the same type of error and I cannot for anything figure out what is going on.

The error says “actual and formal argument lists differ in length” but they don’t do they?
There are four variables in the Language class (protected String name; protected int numSpeakers; protected String regionsSpoken; protected String wordOrder;)

This is exactly what the Get Hints pop-out suggests!

My instantiation call gives four arguments. This isn’t even a problem with the child classes. This is a very basic syntax error I’m guessing but I cannot figure this one out. Can anyone help?

Here is my code:

class Language{

protected String name;
protected int numSpeakers;
protected String regionsSpoken;
protected String wordOrder;

public void aLanguageConstructor(String nom,int numSpkrs,String rgnsSpkn, String wordOrd){
name = nom;
numSpeakers = numSpkrs;
regionsSpoken = rgnsSpkn;
wordOrder = wordOrd;
}

public void getInfo(){
System.out.println(this.name + " is spoken by " + this.numSpeakers + " people mainly in " + this.regionsSpoken + “.”);
System.out.println(" The language follows the word order: " + this.wordOrder + “.”);
}

public static void main(String args) {
Language spanish = new Language(“Spanish”, 555000000, “Spain, Latin America, and Equatorial Guinea”, “subject-verb-object”);
spanish.getInfo();

//Language kabibble = new Language();
//kabibble.getInfo();
//Mayan chontal = new Mayan("Chontal",36810);

// chontal.getInfo();
//SinoTibetan chinese = new SinoTibetan(“Mandarin Chinese”,8000000);
//SinoTibetan nonChinese = new SinoTibetan(“Burmese”,1000000);
}

}

1 Like

So I have narrowed it down to the Maya.java child code. It says it cannot find the symbol languageName.

Even though languageName is one of the parameters of the class in the super statement and more frustratingly the same thing works in the SinoTibetan.java class (see below Mayan). What is going on here? Does the @Override do something to the scope of the variables? Is it a scope problem?

Here is the code:

class Mayan extends Language{

Mayan(String languageName, int speakers) {
super (languageName, speakers, “Central America”, “verb-object-subject”);
}

@Override
public void getInfo() {
System.out.println(languageName + " is spoken by " + speakers + " people mainly in " + regionsSpoken + “.”);
System.out.println(" The language follows the word order: " + wordOrder + “.”);
System.out.println(“Fun fact: " + name + " is an ergative language.”);
}
}

and the SinoTibetan.java class:

class SinoTibetan extends Language {

SinoTibetan(String languageName, int speakers) {
super(languageName, speakers, “Asia”, “subject-object-verb”);
if (languageName.contains(“Chinese”) ) {
wordOrder = “subject-verb-object”;
}
}
}

One problem was with the constructor method which should not be a public void method but simply named with the name of the class. I caught that!

The same thing happens when I try to reference this.languageName also. So it is not that.

I am stuck at 4/9, getting errors “cannot find symbol”, on these lines:

this.name = langName;
this.numSpeakers = speakers;
this.regionsSpoken = regions;
this.wordOrder = order;

with the “arrow” pointing at “l” in “langName”, “s” in “speakers”, “r” in “regions” and “o” in “order”

Ended up checking with “Get a hint”, its written exactly the same, still error.

Hey guys,

I’m also stuck on the Language Families project, more precisely on task 8. I have no idea what the problem is. The error message is as follows:

Language.java:20: error: ‘;’ expected
public void getInfo() {
^
1 error

Here is my code for the Language class:

class Language {

  protected String name;
  protected int numSpeakers;
  protected String regionsSpoken;
  
  protected String wordOrder;

  Language(String langName, int speakers, String regions, String wdOrder) {
    this.name = langName;
    this.numSpeakers = speakers;
    this.regionsSpoken = regions;
    this.wordOrder = wdOrder;
  }

  public void getInfo() {
    System.out.println(this.name + " is spoken by " + this.numSpeakers + " people mainly in" + this.regionsSpoken + ". The language follows the order: " + this.wordOrder + ".");
  
 @Override
  public void getInfo() {
 
    System.out.println(this.name + " is spoken by " + this.numSpeakers + " people mainly in " + this.regionsSpoken + ".");
    System.out.println("The language follows the word order: " + this.wordOrder);
    System.out.println("Fun fact: " + this.name + " is an ergative language.");
 
  }
  
  }

  public static void main(String[] args) {
    Language spanish = new Language("Spanish", 555000000, "Spain, Latin America, and Equatorial Guinea", "subject-verb-object");
    spanish.getInfo();

    Mayan yucatec = new Mayan("Yucatec", 812633);
    yucatec.getInfo();

  }
}

And this is the code for the child class called Mayan:

class Mayan extends Language {
  Mayan(String langName, int speakers) {
    super(languageName, speakers, "Central America", "verb-object-subject");
  }

}

Hope someone can help me with this thank you in advance!

Okay guys I will reply to myself because I found the problem:

If you take a look at the child class Mayan you can see that I named the String in the parameters ‘langName’ instead of languageName. However, the knowledge does not solve my problem of understanding. I don’t understand the fact that I can rename this Parameter. I thought that I have to name it exactly as the variables in the constructor. Hope someone understand my question.

1 Like

I know this is too late but better now than never. So in the Mayan constructor you set 2 parameters, then in super you placed a different parameter for langName and put languageName instead. Now the constructor knows that it should receive a String and hold it in the parameter variable called langName, however, it does not recognize the languageName variable and it doesn’t know where it came from.

Note: Also a common mistake which led me here is…when placing the variables in the super do not write before it a datatype like so; super(String langName). Do it without like so; super( langName).