import java.util.*; public class Movies { String locations[]; String movies[][]; Movies(String s) { Vector vlocations = new Vector(); Vector vmovies = new Vector(); String keyTheatre = "{!-- THEATER --}"; while ((s.indexOf(keyTheatre)) == 0) { Vector vshowings = new Vector(); String location; location = s.substring(keyTheatre.length()+2); int i = location.indexOf(" "); int j = location.indexOf("\n"); if (i>0 && (j<0 || i 0) { location = location.substring(0, j); } vlocations.addElement(location); String r; i = s.substring(1).indexOf(keyTheatre); if (i<0) { r = s; s = ""; } else { r = s.substring(0, i+1); s = s.substring(i+1); } String keyMovie1 = "{!-- LHS MOVIE --}"; String keyMovie2 = "{!-- RHS MOVIE --}"; while (r.indexOf(" MOVIE --}") >= 0) { i = r.indexOf(keyMovie1); j = r.indexOf(keyMovie2); if (i < 0 || (i >= 0 && j >= 0 && j < i)) { i = j; } if (i >= 0) { r = r.substring(i+keyMovie1.length()+2); String title = r; String rating = ""; String duration = ""; int minutes = 0; String showings = ""; String keyShowInfo = "{!-- SHOW INFO --}"; i = r.indexOf('\n'); if (i >= 0) { title = r.substring(0, i); r = r.substring(i+1); rating = r; i = r.indexOf(' '); j = r.indexOf('\n'); if (j >= 0 & j < i) { i = j; } j = r.indexOf(keyShowInfo); if (j >= 0 & j < i) { i = j; } } if (i >= 0) { rating = r.substring(0, i); r = r.substring(i+1); duration = r; i = r.indexOf('\n'); j = r.indexOf(keyShowInfo); if (j >= 0 & j < i) { i = -1; duration = ""; } } if (i >= 0) { duration = r.substring(0, i); r = r.substring(i+1); } i = r.indexOf(keyShowInfo); if (i >= 0) { r = r.substring(i+keyShowInfo.length()+2); showings = r; i = r.indexOf("\n"); } if (i >= 0) { showings = r.substring(0, i); } String movie = title + ' ' + rating + ' ' + duration + ' ' + showings; while ((i = movie.indexOf(" ")) >= 0) { if (i == 0) { movie = movie.substring(1); } else { movie = movie.substring(0, i) + movie.substring(i+1); } } vshowings.addElement(movie); } } vmovies.addElement(vshowings); } // copy vectors into arrays locations = new String[vlocations.size()]; for (int i=0; i