Computer Science A - Mrs. Bucaria

Add Method MakePet to your AsciiAnimalProg between the last two brackets

Topic - Inheritance and Composition

Key Points to remember

  • An AsciiPet is an abstract class with two methods that each AsciiObjects class must write code to. The drawPet() and the Speak() methods.
  • An AsciiPetOwner is an AsciiMan (INHERITANCE) with one extra data variable that is type AsciiPet. (COMPOSITION)

    Write a program called AnimalMania that utilizes our classes from AsciiProg that we have worked so hard to perfect. The program should do the following:

  • Construct three distinct AsciiPets by asking the user of the program what the name and the type of the animal will be. Call the AsciiPets pet1,pet2 and pet3. When constructing them use the following code AsciiPet pet1=new AsciiDog("ccc"); Remember that each animal will be DYNAMICALLY BOUND to the classes for it's constructed type.
  • Construct three AsciiPetOwners with three different names who each own one of the pets above. Ask the user for each owners name...you can assign pet to owner however you want to.
  • Print out each owners pictures then their animals picture.
  • Print out a table with the owners name and then the animals name and sound.
  • Swap the three animals around so each owner has a different animal.
  • Re-print the table.
  • Do something to make this more interesting!!!

    HAVE FUN!!!!!