import java.util.Scanner;
import java.util.ArrayList;
/**
 * A textual driver to test the psychology experiment scheduler.
 * 
 * @author CS1 Spring 2006
 * @version 1.5
 */
public class TextualScheduleTester {

  /** Exercise the Schedule class. */
  public static void main(String[] args) {
    System.out.println("Schedule Tester\n");
    Schedule sched = new Schedule();
    Scanner sc = new Scanner(System.in);
    // Check computation of number of sessions
    System.out.print("Please enter the number of students: ");
    String input = sc.next();
    int numStudents = Integer.parseInt(input);
    System.out.println(numStudents
                     + " students will require "
                     + sched.numSessions(numStudents)
                     + " sessions.\n");
    // Check computation of number of trainers
    System.out.print("How many training periods do you have? ");
    input = sc.next();
    int numPeriods = Integer.parseInt(input);
    System.out.println("You can train "
                       + sched.numTrainers(numPeriods)
                       + " experimenters in "
                       + numPeriods
                       + " periods.\n");
    // Check computation of number of periods
    System.out.print("How many experimenters do you need to train? ");
    input = sc.next();
    int numExperimenters = Integer.parseInt(input);
    System.out.println("It will take "
                       + sched.numPeriods(numExperimenters)
                       + " periods to get at least "
                       + numExperimenters
                       + " trained experimenters.\n");
     // Check adding rooms to a room list.
     ArrayList<Room> roomList;
     System.out.println("** Room Data Entry **");
     roomList = addRooms();
     System.out.println("Here are the rooms that you entered:");
     for (Room r : roomList) {
       System.out.println(r.getBuilding() + " " + r.getRoomNumber());
     }
  }
  
  /**
   * Create a list of rooms with information entered by the user
   * at the console.
   * @return list of rooms
   */
  public static ArrayList<Room> addRooms() {
    Scanner sc = new Scanner(System.in);
    System.out.print("Do you want to enter another room? [y or n]: ");
    String answer = sc.nextLine();
    if (answer.substring(0,1).equalsIgnoreCase("n")) {
      return new ArrayList<Room>();
    }
    System.out.print("Building: ");
    String bldg = sc.nextLine();
    System.out.print("Room number: ");
    String rmn = sc.nextLine();
    Room newRoom = new Room(bldg, rmn);
    ArrayList<Room> theRooms = addRooms();
    theRooms.add(0, newRoom);
    return theRooms;
  }
}
