Java Reference
In-Depth Information
bookingsTableHTML += this.bookings[booking].getCustomerName();
bookingsTableHTML += “</td>”;
bookingsTableHTML += “<td>”;
bookingsTableHTML += this.bookings[booking].getFilm();
bookingsTableHTML += “</td>”;
bookingsTableHTML += “<td>”;
bookingsTableHTML += this.bookings[booking].getShowDate();
bookingsTableHTML += “</td>”;
bookingsTableHTML += “</tr>”;
}
bookingsTableHTML += “</table>”;
return bookingsTableHTML;
}
var londonOdeon = new Cinema();
londonOdeon.addBooking(342, “Arnold Palmer”,”Toy Story”, “15 July 2009 20:15”);
londonOdeon.addBooking(335, “Louise Anderson”,
“The Shawshank Redemption”, “27 July 2009 11:25”);
londonOdeon.addBooking(566, “Catherine Hughes”,
“Never Say Never”, “27 July 2009 17:55”);
londonOdeon.addBooking(324, “Beci Smith”,”Shrek”, “29 July 2009 20:15”);
document.write(londonOdeon.getBookingsTable());
</script>
</body>
</html>
Your new code is
var londonOdeon = new cinema();
londonOdeon.addBooking(342, “Arnold Palmer”,”Toy Story”, “15 July 2009 20:15”);
londonOdeon.addBooking(335, “Louise Anderson”,
“The Shawshank Redemption”, “27 July 2009 11:25”);
londonOdeon.addBooking(566, “Catherine Hughes”,
“Never Say Never”, “27 July 2009 17:55”);
londonOdeon.addBooking(324, “Beci Smith”,”Shrek”, “29 July 2009 20:15”);
document.write(londonOdeon.getBookingsTable());
These create a new cinema object and store a reference to it in the variable
londonOdeon
. You then cre-
ate four new bookings using the
Cinema
type's
addBooking()
method. On the fi nal line, you write the
HTML returned by the
getBookingsTable()
method to the page.
Your page should now look like that shown in Figure 5-7.