Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dwong28
- /**
- * Write a description of class GenericUtilities here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class GenericUtilities
- {
- public static <SomeType> boolean search (SomeType [] theArray, SomeType target)
- {
- for (int arrayPosition = 0; arrayPosition < theArray.length; arrayPosition++)
- {
- if (theArray[arrayPosition].equals(target))
- {
- return true;
- }
- }
- return false;
- }
- public static <SomeType> void print (SomeType [] theArray)
- {
- for(SomeType arrayValue : theArray)
- {
- System.out.println(arrayValue);
- }
- }
- }
- cflorka
- /**
- * Lab04 Generic search and print.
- *
- * @author Clint Florka
- * @author Samuel Stearns
- * @version 1-13-14
- */
- public class GenericUtilities
- {
- /**
- * Searches an array.
- *
- * @param theArray the array to check
- * @param target the Object checked
- * @return true if the target is in the array, false else
- */
- public static <SomeType> boolean search (SomeType [] theArray, SomeType target)
- {
- boolean inArray = false;
- for(int index = 0; index < theArray.length; index++)
- {
- if(theArray[index].equals(target))
- {
- inArray = true;
- }
- }
- return inArray;
- }
- /**
- * Prints each element of the array.
- *
- * @param theArray the array to print
- */
- public static <SomeType> void print (SomeType [] theArray)
- {
- for(int index = 0; index < theArray.length; index++)
- {
- System.out.println(theArray[index]);
- }
- }
- }
- goscott
- icotteng
- /**
- * Write a description of class GenericUtilities here.
- *
- * @author Ian Cottengim, Akshay Sharma
- * @version 1/13/14
- */
- public class GenericUtilities
- {
- public static <SomeType> boolean search (SomeType [] theArray, SomeType target)
- {
- boolean found = false;
- for(SomeType generic : theArray)
- {
- if(generic.equals(target))
- {
- found = true;
- }
- }
- return found;
- }
- public static <SomeType> void print (SomeType [] theArray)
- {
- for(SomeType generic : theArray)
- {
- System.out.print(generic + " ");
- }
- System.out.println();
- }
- }
- iswilson
- import java.util.*;
- /**
- * Searches and Prints lists of Objects
- *
- * @author Ian Meeder & Ian Wilson
- * @version Lab 4
- */
- public class GenericUtilities
- {
- /**
- * Searches through and finds target in object array.
- * @param theArray array of objects
- * @param target the element to be searched for
- * @return true if found, false otherwise
- */
- public static <SomeType> boolean
- search(SomeType [] theArray, SomeType target)
- {
- boolean bool = false;
- for (int count = 0; count < theArray.length; count++)
- {
- if (theArray[count].equals(target))
- {
- bool = true;
- }
- }
- return bool;
- }
- /**
- * Prints out all elements in an array.
- * @param theArray the array to print
- */
- public static <SomeType> void print (SomeType [] theArray)
- {
- for (SomeType item : Arrays.asList(theArray))
- {
- System.out.print(item + " ");
- }
- }
- }
- jchoi30
- /**
- * Implements generic methods to be used on arrays of any type.
- *
- * @author Josh Choi and John Shamshoian
- * @version Lab 4
- */
- public class GenericUtilities
- {
- /**
- * Linear search method.
- *
- * @param theArray The array to be passed in.
- * @param target The object that the method searches for.
- */
- public static < SomeType > boolean search
- (SomeType [] theArray, SomeType target)
- {
- boolean result = false;
- for (int itor = 0; itor < theArray.length; itor++)
- {
- if (theArray[itor].equals(target) || result == true)
- {
- result = true;
- }
- else
- {
- result = false;
- }
- }
- return result;
- }
- /**
- * Prints every element in the array.
- *
- * @param theArray the generic array to print.
- */
- public static < SomeType > void print (SomeType [] theArray)
- {
- for (SomeType item : theArray)
- {
- System.out.println(item.toString());
- }
- }
- }
- jlroman
- /**
- * This class will search and print elements of any type in an array.
- *
- * @author Connor Batch, Jose Roman
- * @version 1/13/14
- */
- public class GenericUtilities
- {
- /**
- * Searches for element in array.
- *
- * @SomeType[] array containing all the elements.
- * @SomeType element that is being searched for.
- *
- * @return boolean true or false if found.
- */
- public static <SomeType> boolean search(SomeType[] theArray, SomeType target)
- {
- boolean found = false;
- /*Will iterate through the array.*/
- for (int index = 0; index < theArray.length; index++)
- {
- /*Determine if found.*/
- if (theArray[index].equals(target))
- {
- found = true;
- }
- }
- return found;
- }
- /**
- * Prints out elements in array
- *
- * @SomeType[] array containing all the elements.
- */
- public static <SomeType> void print(SomeType[] theArray)
- {
- /*Will iterate and print elements.*/
- for (SomeType element : theArray)
- {
- System.out.println(element);
- }
- }
- }
- jsvillat
- /**
- * A class that searches through an array of a generic type
- * and prints out every element.
- *
- * @author Saul Villatoro
- * @author Mitch Lane
- * @version 1/13/14
- */
- public class GenericUtilities
- {
- /**
- * Searches through the array of generic objects for a specific element.
- *
- * @param <SomeType> The method type
- * @param theArray An array of type SomeType of generic objects.
- * @param target A SomeType object being searched for.
- * @return toReturn A boolean of true if found.
- */
- public static <SomeType> boolean search(SomeType [] theArray, SomeType target)
- {
- boolean toReturn = false;
- // Goes through each element in the array
- for(SomeType element : theArray)
- {
- // If the element being searched is found
- if(target.equals(element))
- {
- toReturn = true;
- }
- }
- return toReturn;
- }
- /**
- * Prints each element in an array of generic objects.
- * @param <SomeType> The method type
- * @param theArray An array to be printed
- */
- public static <SomeType> void print(SomeType [] theArray)
- {
- // Goes through each element in the array
- for(SomeType element : theArray)
- {
- System.out.println(element.toString());
- }
- }
- }
- katong
- import java.util.*;
- import java.lang.*;
- /**
- * GenericUtilities contains a search and print method.
- *
- * @author Zach Ho
- * @author Ka Tong
- * @version 1/13
- */
- public class GenericUtilities
- {
- /**
- * A simple linear search method
- *
- * @param theArray input array
- * @param target what you're searching for
- * @return did you find what you were looking for? t/f
- */
- public static <SomeType> boolean search(SomeType[] theArray, SomeType target)
- {
- boolean found = false;
- for(int i = 0; i< theArray.length; i++)
- {
- if(theArray[i].equals(target))
- {
- found = true;
- }
- }
- return found;
- }
- public static <SomeType> void print(SomeType[] theArray)
- {
- for(int i = 0; i<theArray.length; i++)
- {
- System.out.println(theArray[i]);
- }
- }
- }
- mjzhang
- /**
- * Implements a generic linear seach method and generic print method.
- *
- * @author Marek Zhang, Neha Jagannath, Darren Mistica
- *
- * @version 2014.0
- */
- public class GenericUtilities
- {
- public static <SomeType> boolean search (SomeType [] theArray, SomeType target)
- {
- int index;
- boolean result = false;
- for(index = 0; index < theArray.length; index++)
- {
- if(theArray[index].equals(target))
- {
- result = true;
- }
- }
- return result;
- }
- public static <SomeType> void print (SomeType [] theArray)
- {
- int index;
- for(index = 0; index < theArray.length; index++)
- {
- System.out.println(theArray[index]);
- }
- System.out.println();
- }
- }
- ptran17
- /**
- * A class containing methods that can used for generic classes.
- *
- * @author Dat Tran, Liam Kirsh
- * @version 1-13-2014
- */
- public class GenericUtilities
- {
- /**
- * Performs a sequential search of an array
- *
- * @param theArray the array of SomeType to be searched
- * @param target the target to search for
- * @return true if found, false otherwise
- */
- public static <SomeType> boolean search(SomeType[] theArray,
- SomeType target)
- {
- boolean result = false;
- for (int index = 0; index < theArray.length && !result; ++index)
- {
- if (theArray[index].equals(target))
- {
- result = true;
- }
- }
- return result;
- }
- /**
- * Prints the array
- *
- * @param theArray the array of SomeType to be printed
- */
- public static <SomeType> void print(SomeType[] theArray)
- {
- for (SomeType value : theArray)
- {
- System.out.println(value);
- }
- }
- }
- tduong08
- /**
- * GenericUtilities aims to provide simple methods that programmers can reuse for both
- * debuging and other purposes.
- *
- * @author Nikolai Shkurkin, Tommy Duong
- * @version Lab 4
- *
- */
- public class GenericUtilities
- {
- /**
- * Blah blah
- *
- * @param <SomeType> The type of the array that is to be searched
- * @param theArray A C-style array to be searched
- * @param target The item to try to find
- * @return A boolean representing if the target was found in the array.
- */
- public static <SomeType> boolean search(SomeType [] theArray, SomeType target)
- {
- boolean found = false;
- //Iterates through tehArray and stops if target is found
- for (int index = 0; (index < theArray.length) && !found; index++)
- {
- SomeType element = theArray[index];
- //Determining if element was found
- if (target == null || element == null) //Either is "null"
- {
- found = (element == target);
- }
- else //Objects are initialized
- {
- found = element.equals(target);
- }
- }
- return found;
- }
- /**
- * Prints the contents of any array.
- *
- * @param <SomeType> The type of the array that is to be printed
- * @param theArray The C-style array whose contents are to be displayed
- */
- public static <SomeType> void print(SomeType [] theArray)
- {
- //Prints each element of the array
- for (SomeType element : theArray)
- {
- System.out.println(element);
- }
- }
- }
- vmvilla
- import java.util.*;
- /**
- * This class recieves an array of any type.
- * Contains methods to search array for specified object
- * and to print all Objects in the array.
- *
- * @author Cory Kross, Vanessa Villa
- * @version Lab4
- */
- public class GenericUtilities
- {
- public GenericUtilities()
- {
- }
- /**
- * Searches array for specified object
- *
- * @param target The object that will be searched for
- * @param <SomeType> A generic object
- * @param theArray The array to search through
- *
- * @return boolean True if object found
- */
- public static <SomeType> boolean search(SomeType [] theArray, SomeType target)
- {
- boolean res = false;
- //loops through array until target found
- for(int indx = 0; indx < theArray.length ; indx++ )
- {
- //Checks index for target
- if( theArray[indx].equals(target) )
- {
- res = true;
- indx = theArray.length;
- }
- }
- return res;
- }
- /**
- * Prints the objects within the array
- *
- * @param theArray The Array which will print
- * @param <SomeType> A generic object
- */
- public static <SomeType> void print(SomeType [] theArray)
- {
- //Loops through the entire array
- for(SomeType type : theArray)
- {
- System.out.println(type);
- }
- }
- }
- zho
- /**
- * GenericUtilities contains a search and print method.
- *
- * @author Zach Ho and Ka Tong
- * @version 1/13
- */
- import java.util.*;
- import java.lang.*;
- public class GenericUtilities
- {
- /**
- * A simple linear search method
- *
- * @param theArray input array
- * @param target what you're searching for
- * @return did you find what you were looking for? t/f
- */
- public static <SomeType> boolean search(SomeType[] theArray, SomeType target)
- {
- boolean found = false;
- for(int i = 0; i< theArray.length; i++)
- {
- if(theArray[i].equals(target))
- {
- found = true;
- }
- }
- return found;
- }
- public static <SomeType> void print(SomeType[] theArray)
- {
- for(int i = 0; i<theArray.length; i++)
- {
- System.out.println(theArray[i]);
- }
- }
- }
- apolcyn
- /**
- * Linear Search and Print methods on generic types.
- *
- * @author Alex Polcyn, Sank Yang
- * @version 01/13/14
- */
- public class GenericUtilities
- {
- /**
- * Implementation of a linear search.
- *
- * @param theArray an array of generic objects
- * @param target the item being search for in the array
- *
- * @return boolean Whether or not the target is found
- */
- public static <SomeType> boolean search (SomeType [] theArray, SomeType target)
- {
- int index = 0; // The index used to iterate through the array
- boolean found = false; // The flag used to tell if the target has been found
- // Searches for the target in the list. Ends when target has been found or
- // end of list has been reached.
- while(found == false && index < theArray.length)
- {
- // Checking if the list item at the current index matches the target.
- if(theArray[index].equals(target))
- {
- found = true;
- }
- index++;
- }
- return found;
- }
- /**
- * Prints all the items in the array.
- *
- * @param theArray the array of generic objects
- */
- public static <SomeType> void print (SomeType [] theArray)
- {
- // Iterates through the array and prints every item
- for(SomeType element : theArray)
- {
- System.out.println(element.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment