Python's equivalence?
Posted
by user304014
on Stack Overflow
See other posts from Stack Overflow
or by user304014
Published on 2010-03-29T07:17:52Z
Indexed on
2010/03/29
7:23 UTC
Read the original article
Hit count: 411
python
Is there anyway to transform the following code in Java to Python's equivalence?
public class Animal{
public enum AnimalBreed{
Dog, Cat, Cow, Chicken, Elephant
}
private static final int Animals = AnimalBreed.Dog.ordinal();
private static final String[] myAnimal = new String[Animals];
private static Animal[] animal = new Animal[Animals];
public static final Animal DogAnimal = new Animal(AnimalBreed.Dog, "woff");
public static final Animal CatAnimal = new Animal(AnimalBreed.Cat, "meow");
private AnimalBreed breed;
public static Animal myDog (String name) {
return new Animal(AnimalBreed.Dog, name);
}
}
© Stack Overflow or respective owner