123456789101112131415161718192021222324252627282930313233 |
- /**
- * Created by leon on 11/6/17.
- */
- public class MainApplication {
-
- public void runCreatePetList()
- {
- Console console = new Console();
- int numberOfPets = console.userSetNumberOfPets();
- Pet[] pets = new Pet[numberOfPets];
- Pet aPet = new Pet();
- for(int i=0; i<=numberOfPets-1; i++)
- {
- aPet.setTypeOfPet();
- aPet.setNameOfPet();
- if(aPet.getTypeOfPet().equalsIgnoreCase("dog"))
- {
- Dog aDog = new Dog(aPet.getTypeOfPet(), aPet.getNameOfPet());
- pets[i] = aDog;
- } else if(aPet.getTypeOfPet().equalsIgnoreCase("cat")){
- Cat aCat = new Cat(aPet.getTypeOfPet(), aPet.getNameOfPet());
- pets[i] = aCat;
- } else if(aPet.getTypeOfPet().equalsIgnoreCase("tortoise")){
- Tortoise aTortoise = new Tortoise(aPet.getTypeOfPet(), aPet.getNameOfPet());
- pets[i] = aTortoise;
- } else {
- pets[i] = aPet;
- }
- }
- console.printPets(pets);
- }
- }
|