Using ArrayList and Extends

I'm trying to set up my arraylist in my Animal class but should it be in my AnimalDisplayList instead?  Also if I'm trying to get the type of Bird through the Bird class should I set the static variables to ints so that the user can just get a #?  Also I've used ints in my animal class for size but I don't know If i've stated them correctly.  I'm also getting errors on my ENUM but I don't really understand why...  Is enum supposed to be in a class by itself?  Any help is appreciated.    Here are the errors I'm getting:  

Animal.java:38: ',', '}', or ';' expected
         BEAGLE = 0,
                ^
Animal.java:38: '}' expected
         BEAGLE = 0,
                 ^
Animal.java:39: <identifier> expected
                  PITBULL = 1;
                         ^
Animal.java:40: <identifier> expected
                  LABRADOR = 2;
                          ^
etc...


    public class AnimalListDisplay extends JList
   {
   
       public AnimalListDisplay()
      {
      }
       public void sortAge()
      {
      }
       public void filterAge()
      {
      }
   
       public void sortID()
      {
      }
       public void filterID()
      {
      }
   
   
       public void sortSpecialNeeds()
      {
      }
   
   
       public void filterSpecialNeeds()
      {
      }
   
       public void sortDescription()
      {
      }
   
   
       public void filterDescription()
      {
      }
   
       public void sortSize()
      {
      }
       public void filterSize()
      {
      }
   
   }

    public class Bird extends Animal
   {
      public static final String PARROT;
      public static final String OUTDOOR;
      public static final String SMALL;
   
       public Bird()
      {
         super(aniID, aniAge, aniSize, aniNeeds, animalDesc);
     
         String type;
         
            
         
            
     
      }
   }
public abstract class Animal 
   {
      protected int id;
      protected int age;
      protected int size;
      protected String needs;
      protected String description;
		public static final int GIANT = 1;
		public static final int LARGE = 2;
		public static final int MEDIUM = 3;
		public static final int SMALL = 4; 
		public static final int MINIATURE = 5;
		public static final int CATSIZE = 6;
		public static final int BIRDSIZE = 7;
   
       public Animal()
      {
         id = 0;
         age = 0;
         size = 0;
         needs = ("");
         description = ("");
      
      
      }
   
       public Animal(int aniId, int aniAge, int aniSize, String aniNeeds, String animalDesc)
      {
         this.id = aniId;
         this.age = aniAge;
         this.size = aniSize;
         this.needs = aniNeeds;
         this.description = animalDesc;
      }
		
		   public enum setSize
		       {
         BEAGLE = 0,
			PITBULL = 1;
			LABRADOR = 2;
		   BULLDOG = 3;
   GREYHOUND = 4;
    LOVEBIRD = 5;
  MACAW = 6;
   ROBIN = 7;
   CHICKEN = 8;
     GOLDENEAGLE = 9;
     TABBY = 10;
     SIAMESE = 11;
      SINGAPURA = 12;
     BURMESE = 13;
     SPHYNX = 14;


      }
   	public void setAnimal(AnAnimal type)
	
   	{
		
		
   	
   // 	int 00000 = dog1;
//    	int 00001;
//    	int 00002;
//    	int 00003;
//    	int 00004;
//    	int 00005;
//    	int 00006; 
//    	int 00007;
//    	int 00008;
//    	int 00009;
//    	int 00010;
//    	int 00011;
//    	int 00012;
//    	int 00013;
//    	int 00014;
//    	int 00015;
   	
//    	ArrayList < Animal > list = new ArrayList<Animal>;
   	
   	
		}
    			
      
      
     // ArrrayList <Dog> dogSize = new ArrayList<Dog>
      //dogSize.add(5);
      
      
      
      }
       public int getSize()
      {
      
         return size;
      }
      
          
   }

Open in new window

Slck_PAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

robthewolfCommented:
In my solution to your last question you will notice that i didnt put numbers in the enum.  The reason is because what enum does is enumerate a list, hence the name.  So you dont need to say CHICKEN = 8.  It is defined as 8.  
read about enums here
http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html
pay particular attention to example about the planets.

I think you want to use your enum as you list of all possible animals, if i understand correctly that it is a completely closed list.  You should read the link i just gave you above and create a new file with the all the animals.

regardless your errors are coming from incorrect usage of the enum.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Slck_PAuthor Commented:
Sorry here's the updated code:


import java.util.ArrayList;
   
   
    public abstract class Animal 
   {
   
   
      // protected int id;
      // protected int age;
      // protected int size;
      // protected String needs;
      // protected String description;
      // public static final int GIANT = 1;
      // public static final int LARGE = 2;
      // public static final int MEDIUM = 3;
      // public static final int SMALL = 4; 
      // public static final int MINIATURE = 5;
      // public static final int CATSIZE = 6;
      // public static final int BIRDSIZE = 7;
      private AnimalType id = null;
      private int age = 0;
      private int size = 0;
      private String needs = "";
      private String description = "";
      
      
       public Animal()
      {
              
      }
   
       public Animal(int aniId, int aniAge, int aniSize, String aniNeeds, String animalDesc)
      {
         this.id = aniId;
         this.age = aniAge;
         this.size = aniSize;
         this.needs = aniNeeds;
         this.description = animalDesc;
      }
   	
   	 	
       enum AnimalType
      { 
         BEAGLE,
         PITBULL,
         LABRADOR,
         BULLDOG,
         GREYHOUND,
         LOVEBIRD,
         MACAW,
         ROBIN,
         CHICKEN,
         GOLDENEAGLE,
         TABBY,
         SIAMESE,
         SINGAPURA,
         BURMESE,
         SPHYNX,
      }   	
      
       public AnimalType getId() {
       
         return id;
      }
       public void setId()
      {
         this.id = id;
      }
       public int getSize(int size)
      {
         return size;
      
      }
       public void setSize()
      {
         this.size = size;
      }
      
       public String getNeeds(String needs)
      {
         return needs;
      }
   	
       public void setNeeds()
      {
         this.needs = needs;
      }
   
       public String getDescription(String description)
      {
         return description;
      }
   
       public void setDescription()
      
      {
         this.description = description;
      }
   
      
       public int getBreed()
      {
         return breed;
      }
      
        
       public void setAnimal(AnAnimal type)
      
      {
      
      
      
      // 	int 00000 = dog1;
      //    	int 00001;
      //    	int 00002;
      //    	int 00003;
      //    	int 00004;
      //    	int 00005;
      //    	int 00006; 
      //    	int 00007;
      //    	int 00008;
      //    	int 00009;
      //    	int 00010;
      //    	int 00011;
      //    	int 00012;
      //    	int 00013;
      //    	int 00014;
      //    	int 00015;
      
      //    	ArrayList < Animal > list = new ArrayList<Animal>;
      
      
      
      		
      
      
      // ArrrayList <Dog> dogSize = new ArrayList<Dog>
      //dogSize.add(5);
      
      
      
      }      
          
   }

Open in new window

0
robthewolfCommented:
The animal class is an abstract class representing a single animal. It should not have an arraylist in it.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Slck_PAuthor Commented:
OK.  If I used the following format with Breed(ID#) would I need to call this in the constructor of Animal?  


import java.util.ArrayList;
   
   
    public abstract class Animal 
   {
   
   
      // protected int id;
      // protected int age;
      // protected int size;
      // protected String needs;
      // protected String description;
      // public static final int GIANT = 1;
      // public static final int LARGE = 2;
      // public static final int MEDIUM = 3;
      // public static final int SMALL = 4; 
      // public static final int MINIATURE = 5;
      // public static final int CATSIZE = 6;
      // public static final int BIRDSIZE = 7;
      private AnimalType id = null;
      private int age = 0;
      private int size = 0;
      private String needs = "";
      private String description = "";
      
      
       public Animal()
      {
              
      }
   
       public Animal(int aniId, int aniAge, int aniSize, String aniNeeds, String animalDesc)
      {
         this.id = aniId;
         this.age = aniAge;
         this.size = aniSize;
         this.needs = aniNeeds;
         this.description = animalDesc;
      }
   	
   	 	
       enum AnimalType
      { 
         BEAGLE(001),
         PITBULL(011),
         LABRADOR(012),
         BULLDOG(013),
         GREYHOUND(014),
         LOVEBIRD(021),
         MACAW(022),
         ROBIN(023),
         CHICKEN(024),
         GOLDENEAGLE(025),
         TABBY(031),
         SIAMESE(032),
         SINGAPURA(033),
         BURMESE(034),
         SPHYNX(035),
      }   	
      
       public AnimalType getId() {
       
         return id;
      }
       public void setId()
      {
         this.id = id;
      }
       public int getSize(int size)
      {
         return size;
      
      }
       public void setSize()
      {
         this.size = size;
      }
      
       public String getNeeds(String needs)
      {
         return needs;
      }
   	
       public void setNeeds()
      {
         this.needs = needs;
      }
   
       public String getDescription(String description)
      {
         return description;
      }
   
       public void setDescription()
      
      {
         this.description = description;
      }
   
      
       public int getBreed()
      {
         return breed;
      }
      
        
       public void setAnimal(AnAnimal type)
      
      {
      
      
      
      // 	int 00000 = dog1;
      //    	int 00001;
      //    	int 00002;
      //    	int 00003;
      //    	int 00004;
      //    	int 00005;
      //    	int 00006; 
      //    	int 00007;
      //    	int 00008;
      //    	int 00009;
      //    	int 00010;
      //    	int 00011;
      //    	int 00012;
      //    	int 00013;
      //    	int 00014;
      //    	int 00015;
      
      //    	ArrayList < Animal > list = new ArrayList<Animal>;
      
      
      
      		
      
      
      // ArrrayList <Dog> dogSize = new ArrayList<Dog>
      //dogSize.add(5);
      
      
      
      }      
          
   }

Open in new window

0
robthewolfCommented:
you have this field:

      private AnimalType id = null;

but you have this in your constructor:
 this.id = aniId;
where aniId is an int.

it should really be
public Animal (AnimalType aniId ......


also your enum is still not quite right.  you have a number after each one is this a specific ID number that is external to the program, if so then its ok, otherwise it is a bit unnecessary.
Regardless, it doesnt do anything.  Reread teh link on enums especially where it comes to the planet example.  It should be clear from that you have something missing.  
As I am going to bed now and can't help you for the next 8 hours I will give you the code.

public enum AnimalType{
             BEAGLE(001),
         PITBULL(011),
         LABRADOR(012),
         BULLDOG(013),
         GREYHOUND(014),
         LOVEBIRD(021),
         MACAW(022),
         ROBIN(023),
         CHICKEN(024),
         GOLDENEAGLE(025),
         TABBY(031),
         SIAMESE(032),
         SINGAPURA(033),
         BURMESE(034),
         SPHYNX(035),

         private final int breedID;
         
         public AnimalType (int id){
             this.breedID = id;
         }
         
         public int getBreedID(){
             return breedID;
         }
}

to get an AnimalType you just need to do:
AnimalType type = AnimalType.TABBY;

good night and good luck
0
CEHJCommented:
>> Is enum supposed to be in a class by itself?

I've already answered that in one of your many earlier questions. The answer is yes
0
Kevin CrossChief Technology OfficerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.