public final class SeatingChartUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static SeatingChart |
loadSeatingChart(java.lang.String fileName)
Load a seating chart from a file, including student preference information.
|
static void |
shuffleSeatingChart(SeatingChart chart)
Randomly reposition all of the students in the provided seating chart.
|
public static SeatingChart loadSeatingChart(java.lang.String fileName) throws java.io.FileNotFoundException
Load a seating chart from a file, including student preference information. The file format is as follows:
ROWS COLS NAME_1 NAME_2 ... NAME_N NAME_1: FRIEND_1, FRIEND_2, ... NAME_2: FRIEND_1, FRIEND_2, ... ... NAME_N: FRIEND_1, FRIEND_2, ...
Where ROWS and COLS are integers, NAMES_1 through NAMES_N are strings, and each FRIEND_X string matches one of the listed names. Duplicate names are not allowed.
Individuals are placed into seats in the order that they appear in the file, starting with the front row (row 0), filling rows from left to right. Each student may have from 0 to N-1 friends. The file must end with a newline character.
fileName
- The name of the file (including the path)java.io.FileNotFoundException
- If the filename does not correspond to a
readable file.public static void shuffleSeatingChart(SeatingChart chart)
chart
- The SeatingChart to shuffle.