Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
2.1 kB
6
Indexable
Never
class Language {

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

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

  // weisse Waage  , schwarze Waage 
  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 mayan = new Language("Mayan",50000,"Latin America", "subject-verb-object");

    mayan.getInfo();

    Mayan urba = new Mayan("Ki'che'", 2330000);

    urba.getInfo();


  SinoTibetan chinese = new SinoTibetan("Mandarin Chinese", 2330000);

  chinese.getInfo();

  SinoTibetan burmese = new SinoTibetan("Burmese", 2330000);


  }
}



class Mayan extends Language {

  Mayan(String name, int numSpeakers){
    super(name,numSpeakers,"Central America","verb-object-subject");
  }

 
  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.");

  }

}




class SinoTibetan extends Language {

  SinoTibetan(String name, int numSpeakers){
    super(name,numSpeakers,"Asia","subject-object-verb");
    if (name.contains("Chinese")) {
      this.wordOrder="subject-verb-object";
    }
  }

  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.");

  }