Skip to content

Instantly share code, notes, and snippets.

@JohnsonLuu
Created June 26, 2020 07:06
Show Gist options
  • Save JohnsonLuu/70e0df384b988e10ffaf16a20222a1ab to your computer and use it in GitHub Desktop.
Save JohnsonLuu/70e0df384b988e10ffaf16a20222a1ab to your computer and use it in GitHub Desktop.
Language Families - Code Academy
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(name + " is spoken by " + numSpeakers + " people mainly in " + regionsSpoken + ". The languauge follows the word order: " + 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 kiche = new Mayan("Kʼicheʼ", 2330000);
kiche.getInfo();
Language chinese = new SinoTibetan("Mandarin Chinese", 920000000);
chinese.getInfo();
Language burmese = new SinoTibetan("Burmese", 33000000);
burmese.getInfo();
}
}
class Mayan extends Language{
// All Mayan languauge share regionsSpoken and wordOrder
Mayan(String langName, int speakers){
super(langName, speakers, "Central America", "verb-object-subject");
}
@Override
public void getInfo(){
System.out.println(name + " is spoken by " + numSpeakers + " people mainly in " + regionsSpoken + ".");
System.out.println("The languauge follows the word order: " + wordOrder + ".");
System.out.println("Fun fact: " + name + "is an ergative languauge.");
}
}
class SinoTibetan extends Language{
SinoTibetan(String langName, int speakers){
super(langName, speakers, "Asia", "subject-object-verb");
if (langName.contains("Chinese")){
this.wordOrder = "subject-verb-object";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment