Today let's play "Pascal says" a variant of Simon says for Java!

How do you play it? Easy. Pascal says: 

I played around with it to get a good grip and used following code to
achieve it (just in case this would help also for others):

class One {
  public static void main(String[] args) {
    Horse a = new Horse();
    Horse b = new Uni();  //works, a bag labeled Horse can contain a Uni since a Uni is a special kind of Horse
    Uni c = new Uni();
//  Uni d = new Horse(); not working, a bag for a Unicorn cannot contain a Horse
    a.talk();
    b.talk();
    c.talk();
    c.talk2();  // works fine, variable and instance are Uni
    Uni.talk2();// works fine, talk2 is static (so can use class name Uni. versus <variable for instance>. )
//  Uni.talk(); // not good, talk is non-static
//  b.talk2();  // wants to find talk2 in Horse cause variable b is of type Horse !! 
                // (as opposed to talk method existing in both Horse and Uni) 
                // --> Q? where is variable type stored and how to get/display it?
  }
}

class Horse {
  void talk() {
    System.out.println(this + " horse");
  }
}

class Uni extends Horse {
  void talk() {
    System.out.println(this + " uni");
  }
  static void talk2() {
    System.out.println("uni talk2");
  }
}

Also we discussed:

class Horse {
  String name;
  void talk() {
    System.out.println("Howdy, I am " + name);
  }
}

class Unicorn extends Horse {
  String name;
  void talk() {
    super.talk();
    System.out.println("Bonjour, ici " + name);
  }
}



Welcome to DrJava.  Working directory is C:\Users\dgerman
> Unicorn a = new Unicorn();
> a.name = "Francois"
"Francois"
> a.talk()
Howdy, I am null
Bonjour, ici Francois
>