Class Driver

java.lang.Object
  extended by Driver

public class Driver
extends java.lang.Object

This class is the driver program for Homework 3 of CMP-338 in the Spring 2015 semester.

Author:
Sameh Fakhouri

Nested Class Summary
static class Driver.ListType
          The ListType enum has the following choices: ArrayBasedList LinkedList
static class Driver.TestType
          The TestType enum has the following choices: AddSortedOdd AddSortedEven AddAll AddAllAtIndexZero RemoveAllEven RemoveAllOdd
 
Constructor Summary
Driver()
           
 
Method Summary
static void clearRunTimes()
          This method clears the array of run times to all zeros
static ListInterface<java.lang.Integer> createTestList(Driver.TestType testType, Driver.ListType listType)
          This method is called by the runTestCase() method to obtain a test list.
static long[] getRunTimes()
          This method returns the array of run times that was generated by the previous call to runTestCase()
static ListInterface<java.lang.Integer> initializeTestList(ListInterface<java.lang.Integer> testList, int firstNumber, int lastNumber, int increment)
          This method is called by the createTestList() method to initialize the test list.
static void main(java.lang.String[] args)
          The main method executes all the test cases.
static void runTestCase(Driver.TestType testType, Driver.ListType listType)
          This method is called to run a particular test case on a list type a total of ten times.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Driver

public Driver()
Method Detail

initializeTestList

public static ListInterface<java.lang.Integer> initializeTestList(ListInterface<java.lang.Integer> testList,
                                                                  int firstNumber,
                                                                  int lastNumber,
                                                                  int increment)
This method is called by the createTestList() method to initialize the test list. The test list could either be an ArrayList or a LinkedList. In either case, it will implement the ListInterface.

Parameters:
testList - The testList to be initialized.
firstNumber - The first number to be added to the list.
lastNumber - The last number to be added to the list
increment - The increment to be used by the for loop for each iteration. If the increment is zero, the test list is left empty.
Returns:
The initialized test list.

createTestList

public static ListInterface<java.lang.Integer> createTestList(Driver.TestType testType,
                                                              Driver.ListType listType)
This method is called by the runTestCase() method to obtain a test list. The test list could either be an ArrayList or a LinkedList. In either case, it will implement the ListInterface. The test list will also be initialized with the correct contents.

Parameters:
testType - The type of test for which the list is being created. This parameter determines how the test list is initialized. The initialization takes place in initializeTestList().
  1. AddSortedOdd
  2. AddSortedEven
  3. AddAll
  4. AddAllAtIndexZero
  5. RemoveAllEven
  6. RemoveAllOdd
listType - The type of list needed. The choices are:
  1. ArrayBasedList
  2. LinkedList
Returns:
The created and initialized test list.
See Also:
initializeTestList(ListInterface, int, int, int)

runTestCase

public static void runTestCase(Driver.TestType testType,
                               Driver.ListType listType)
This method is called to run a particular test case on a list type a total of ten times. The run time for each run is saved in the runTimes array.

Parameters:
testType - The type of test case being run. The choices are:
  1. AddSortedOdd
  2. AddSortedEven
  3. AddAll
  4. AddAllAtIndexZero
  5. RemoveAllEven
  6. RemoveAllOdd
listType - The type of list needed. The choices are:
  1. ArrayBasedList
  2. LinkedList

getRunTimes

public static long[] getRunTimes()
This method returns the array of run times that was generated by the previous call to runTestCase()

Returns:
the runTime array.

clearRunTimes

public static void clearRunTimes()
This method clears the array of run times to all zeros


main

public static void main(java.lang.String[] args)
The main method executes all the test cases.