lundi 2 mars 2020

Java Class Random Database Cats and Dogs

I have cats and dogs that will be made like this (randomly generated) in CreateAnimalshop.java

for(int i=0; i < amountCats; i++){
        minDataBase.add( new Cat(CatName[i], randInt(MAX_CAT_AGE), burNr[teller++] ));
    }

And will be saved as cats and dogs as an extention of the class Animal (that gets and sets name, age and cageNr):

public Cat(String name, int age, int cageNr);

How do I get the size of Cats and Dogs (the amount of cats and dogs) after this, and a sum of the age of all of them or only cats?




Aucun commentaire:

Enregistrer un commentaire