link to the project: https://www.codecademy.com/courses/learn-java/projects/java-language-families
Hi i have been having problem with the Mayan.java file. Specifically with step 8 of the project. I ran the code on the Language.java file and i get this output.
output: null is spoken by 0 people mainly in Central America.
The language follows the word order: verb-object-subject
Fun fact: null is an ergative language.
My source code:
Language.java:
public class Language{
// instance fields
protected String name;
protected int numSpeakers;
protected String regionsSpeaker;
protected String wordOrder;
//constructor
public Language(String name, int numSpeakers, String regionsSpeaker, String wordOrder){
this.name = name;
this.numSpeakers = numSpeakers;
this.regionsSpeaker = regionsSpeaker;
this.wordOrder = wordOrder;
}
public void getInfo(){
System.out.println(name + " is spoken by\n" +
numSpeakers + " people mainly in " + regionsSpeaker + “\n”
+ "The language follows the word order: " + wordOrder);
}
public static void main(String args){
Language greek = new Language(“Greek”, 200000, “Europe”,“subject-verb-object”);
// call
greek.getInfo();
// call mayan lang
Mayan kiche = new Mayan("Ki'che'",2330000);
kiche.getInfo();
}
}
Mayan.java
public class Mayan extends Language{
int speakers;
String languageName;
public 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 " + regionsSpeaker + ".");
System.out.println("The language follows the word order: " + wordOrder);
System.out.println("Fun fact: " + languageName + " is an ergative language.");
}
}
I am clueless as to how to get around this problem. any help is appreaciated.
Edit: I have found the solution, after just typing things out randomly.
add : this.languageName =this.name; this.speakers = this.numSpeakers;
I still don’t understand how this works, but it works. But any explanation at all is appreaciated.