CSC407 OOP Example

plan.input
Class TestInput

java.lang.Object
  |
  +--plan.input.TestInput
All Implemented Interfaces:
FileInput

public class TestInput
extends java.lang.Object
implements FileInput

A class used for testing other parts of the application. It only pretends to read from a file.


Constructor Summary
TestInput()
           
 
Method Summary
private  int randint(int max)
          Returns a random integer in the range 0..max drawn from a uniform distribution.
 Company readFile(java.lang.String filename)
          Generates test sets of objects depending on the parameter.
private  Company readPlanetaria()
          Generates a pre-determined set of test data.
private  Company readRandom()
          Generates a randomly-determined set of test data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestInput

public TestInput()
Method Detail

readFile

public Company readFile(java.lang.String filename)
                 throws java.io.FileNotFoundException
Generates test sets of objects depending on the parameter. If the parameter is "planetaria.xml", generates a test set cotnaining the product "Planetaria" and a bunch of features.
If the parameter is "random.xml", generates a test set containing randomly generated products and features. Product names are "S<n>".

Specified by:
readFile in interface FileInput
Parameters:
filename - either "planetaria.xml" or "random.xml".
Returns:
a Company object rooting all the data from the test dataset.
Throws:
java.io.FileNotFoundException - when none of the allowed filenames are presented

readPlanetaria

private Company readPlanetaria()
Generates a pre-determined set of test data.

Returns:
a Company object rooting all the data from the test dataset.

readRandom

private Company readRandom()
Generates a randomly-determined set of test data.

Returns:
a Company object rooting all the data from the test dataset.

randint

private int randint(int max)
Returns a random integer in the range 0..max drawn from a uniform distribution.

Parameters:
max - the largest number allowed to be returned
Returns:
a random integer between 0 and max inclusive

CSC407 OOP Example