001    import animals.*;
002    /**
003     * Testing use of interface in different package
004     * 
005     * @author Kristian Torp, torp (at) cs (dot) aau (dot) dk
006     * @version 1.0
007     */
008    public class Exercise8_2 implements animals.Basics {
009            /** Weight in kilos */
010            private float weight;
011    
012            /** Latin name of animal */
013            private String latinName;
014    
015            /**
016             * Constructor for objects of class Exercise8_2
017             */
018            public Exercise8_2() {
019                    // initialise instance variables
020                    weight = 0;
021                    latinName = "";
022            }
023    
024            /**
025             * Constructor for objects of class Exercise8_2
026             */
027            public Exercise8_2(float weight, String latineName) {
028                    this.weight = weight;
029                    this.latinName = latineName;
030            }
031    
032            /**
033             * Overridding of toString method
034             */
035            public String toString() {
036                    return "Name: " + latinName + " weight: " + weight;
037            }
038    
039            /**
040             * Gets the Latin name
041             * 
042             * @return Latin name
043             */
044            public String getLatinName() {
045                    return latinName;
046            }
047    
048            /**
049             * Gets the weight.
050             * 
051             * @return weight in kilos
052             */
053            public float getWeight() {
054                    return weight;
055            }
056    
057            /**
058             * Sets the weigth
059             * 
060             * @weight the new weight
061             */
062            public void setWeight(float weight) {
063                    this.weight = weight;
064            }
065    
066            /**
067             * Main method for exercising the code.
068             * 
069             * @param args
070             */
071            public static void main(String[] args) {
072                    // Get a default
073                    Exercise8_2 c1 = new Exercise8_2();
074                    System.out.println(c1);
075                    Exercise8_2 dog = new Exercise8_2(40.4f, "Canis Familaris");
076                    System.out.println(dog);
077            }
078    }