forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
50 lines (40 loc) · 1.38 KB
/
Copy pathAnimal.java
File metadata and controls
50 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import javax.xml.bind.annotation.XmlAttribute;
//@XmlRootElement
//@XmlRootElement(name = "myanimal")
//@XmlType(propOrder = {"species", "name"}) // if used must specify all
public class Animal
{
public static enum AnimalClass { mammal, reptile, bird, fish, amphibian, invertebrate }
@XmlAttribute
//@XmlAttribute(name = "class")
public AnimalClass animalClass;
public String name, species, habitat, food, temperament;
public Double weight;
public FoodRecipe foodRecipe;
public Animal() { }
public Animal(
AnimalClass animalClass, String name, String species, String habitat,
String temperament, Double weight, String food )
{
this.animalClass = animalClass;
this.name = name;
this.species = species;
this.habitat = habitat;
this.food = food;
this.temperament = temperament;
this.weight = weight;
}
public Animal(
AnimalClass animalClass, String name, String species, String habitat,
String temperament, Double weight, FoodRecipe foodRecipe )
{
this.animalClass = animalClass;
this.name = name;
this.species = species;
this.habitat = habitat;
this.temperament = temperament;
this.weight = weight;
this.foodRecipe = foodRecipe;
}
public String toString() { return name +"("+animalClass+", "+species+")"; }
}