package singleton.eagerLogger;

public class Driver {

	public static void main(String[] args) throws InterruptedException {
		
		/* NOTE:  By accessing a method in the Logger class, we
		 * are loading that class
		 */		
		System.out.println(Logger.getSingletonType() + " INSTANTIATION");
		
		/* Driver will sleep for one second before doing any logging.
		 * to differentiate lazy vs eager instantiation.
		 */
		System.out.println("\tPlease wait. I am taking my time...");
		Thread.sleep(1000);
		
		// Now perform loggable activities
		Course course1 = new Course("THD", "07.360", "Musical Theatre");  sleep();
		Student ricky = new Student(3907, "Ricky", "Ricardo", "Music"); sleep();		
		Student fred  = new Student(3911, "Fred", "Mertz", "Engineering"); sleep();		
		Course course2 = new Course("CEE", "08.431", "Solid and Hazardous Waste Management"); sleep();
		course1.add(fred); sleep();
		course1.add(ricky); sleep();
		course2.add(fred); 
		
		// Give user feedback on where activities have been logged.
		Logger logger = Logger.getInstance();
		System.out.println("\tActivity logged to " + logger.getFileName());
	}
	
	private static void sleep() throws InterruptedException {
		Thread.sleep((long) (Math.random() * 2000));
	}

}
