fun main () {

 var A = Animal("Branta","canadenis","Lucy")
 A.Speak()
 A.Move()



 var D = Dog ("Doug","Cocker Spaniel") //Dog inherits from Animal, so it has all the same stuff

 D.Speak ()
 D.Move ()

 var C:Animal = D
 C.Speak()
 C.Move()
 println ("${C.Genus} ${C.Species}")
 println ("${(C as Dog).Breed}")
 //This is called casting.  Actually, it's called unsafe casting.
//I'm telling the compiler, although C is declared as an Animal.
//I know for a fact it's pointing to a Dog, so let it use Dog stuff.
//If I'm right, it works fine.  If I'm not right and C isn't really
//pointing to a Dog, CRASH.
// println ("${(A as Dog).Breed}") //this crashes.

 A.Speak()
 D.Speak()
 var AA:Animal = D
 AA.Speak()

//What will Speak do?
//Even though AA is an Animal pointer, it is pointing to a Dog.
//Since the OBJECT is a Dog, it will run the Dog's method.
//The exact class of POINTER is irrelevant.

 println (A.Species)
 println (D.Species)
 println (D.Name)

 var Zoo = Array<Animal?> (100) {null}
 for (i in 0..Zoo.size-1) {
  val rando = (2*Math.random()).toInt()  //should give me a 0 or 1 randomly
  if (rando==0) Zoo[i] = Animal ("Felis","domesticus","Widdle Muffin Paws")
  else Zoo[i] = Dog ("Crusher","Pit Bull")
 }
 for (anim in Zoo)
  anim!!.Speak()
}
