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);
}

}

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.