/*
 * [Continent.java]
 *
 * Summary: Enumeration of continents and animals that live there.
 *
 * Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2016-09-19 initial version.
 */
package com.mindprod.example;

/**
 * Enumeration of continents and animals that live there.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2016-09-19 initial version.
 * @since 2016-09-19
 */
public enum Continent
    {
        AUSTRALIA( "koala", 4,
                "kangaroo", 2,
                "wombat", 4 ),
        EUROPE( "badger", 4,
                "deer", 4,
                "wolf", 4 ),
        NORTHAMERICA( "bison", 4,
                "black widow spider", 8,
                "lynx", 4,
                "caribou", 4
        );

    /**
     * names of animals
     */
    private final String[] animalNames;

    /**
     * how many legs this animal has
     */
    private final int[] legs;

    /**
     * constructor
     *
     * @param alterate animal name, legs
     */
    Continent( Object... pairs )
        {
        assert ( pairs.length & 1 ) == 0 : "Must have pairs of animal/legs";
        final int p2 = pairs.length / 2;
        this.animalNames = new String[ p2 ];
        this.legs = new int[ p2 ];
        for ( int i = 0; i < p2; i++ )
            {
            animalNames[ i ] = ( String ) pairs[ i * 2 ];
            }
        for ( int i = 0; i < p2; i++ )
            {
            legs[ i ] = ( Integer ) pairs[ i * 2 + 1 ];
            }
        }

    /**
     * get array of animal names
     *
     * @return array of animal names
     */
    public String[] getAnimalNames()
        {
        return animalNames;
        }

    /**
     * get arry of leg counts
     *
     * @return array of leg counts
     */
    public int[] getLegs()
        {
        return legs;
        }
    }