Question
In java complete the sort method on the SortDog class as described below. /** * Class that sorts an array of Dogs. */ public class
In java complete the sort method on the SortDog class as described below.
/** * Class that sorts an array of Dogs. */ public class SortDog extends Dog { /* * Compare one Dog to another Dog. * * If the other Dog is greater than this Dog, returns "bite". * If they are the same, returns "sniff". * If the other Dog is less than this Dog returns "lick". * * @param otherDog other Dog to compare to * @return "bite" if the other Dog is greater, "sniff" if they are the same, * and "lick" if the other Dog is lesser * * public final String compare(final Dog otherDog) */
/** * Sort the array of Dog objects in ascending order. * * You may return either a reference to a new array or to the passed array. * Note that you may not the Arrays utility class. * * You will need to use the Dog compare instance method described above to compare * one Dog to another Dog. * * @param array the array of Dogs to sort * @return a reference to the sorted array */ public static Dog[] sort(final Dog[] array) { return array; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started