driverlab8
By: a guest | Mar 19th, 2010 | Syntax:
Java | Size: 1.90 KB | Hits: 117 | Expires: Never
/**
* This is a driver class that test the proper implementaition of the Person, Student and Employee classes
*/
import acm.program.*;
import acm.util.*;
public class Driver extends ConsoleProgram
{
private Student s;
private Employee e;
private static final RandomGenerator rgen = RandomGenerator.getInstance();
public void run()
{
// Testing Student Class
// Create information needed
String sName = "John Doe";
String sGender = "Male";
String sAddress = "1000 McBryde Hall";
int sID = rgen.nextInt(1, 1000);
// Instantiate an object of the class
s = new Student(sName, sGender);
// Set some values of the object
s.setStudentID(sID);
s.setAddress(sAddress);
s.setCredits(44.5);
s.setPaid(true);
// Print all the data in the object
println("This is the data in the Student object.");
println("--------------------------------------------------");
println( s.toString() );
println();
pause(2000);
// Testing Employee Class
// Create information needed
String eName = "Jane Doe";
String eGender = "Female";
String eAddress = "3000 Torgersen Hall";
int eNumber = rgen.nextInt(1, 30);
// Instantiate an object of the class
e = new Employee(eName, eGender);
// Set some values of the object
e.setENumber(eNumber);
e.setAddress(eAddress);
e.setSalary(6000.0);
e.setActive(true);
// Print all the data in the object
println("This is the data in the Employee object.");
println("--------------------------------------------------");
println( e.toString() );
}
}