Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Horse[] spaces;
- /** Returns the index of the space that contains the horse with the specified name.
- * Precondition: No two horses in the barn have the same name.
- * @param name the name of the horse to find
- * @return the index of the space containing the horse with the specified name;
- * -1 if no horse with the specified name is in the barn.
- */
- public int findHorseSpace(String name){
- int out=-1;
- for(int i=0; i<spaces.length; i++){
- Horse h=spaces[i];
- if(h!=null&&h.getName().equals(name)){
- out=i;
- }
- }
- return out;
- }
- public int findHorseSpace(String name){
- for(int i=0; i<spaces.length; i++){
- if(spaces[i]!=null&&spaces[i].getName().equals(name)){
- return i;
- }
- }
- return -1;
- }
- public int findHorseSpace(String name){
- for(int i=0; i<spaces.length; i++){
- if(spaces[i]!=null){
- if(spaces[i].getName().equals(name)){
- return i;
- }
- }
- }
- return -1;
- }
- public int findHorseSpace(String name){
- int out=-1;
- while(out<0){
- Horse h=spaces[i];
- if(h!=null&&h.getName().equals(name)){
- out=i;
- }
- }
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement