/* * This class extends List to obtain * a list of Halls. * You need not modify this file for Lab 7 * This file may give you ideas as to how to modify * RoomList.java * * Author: Ron Cytron * Class: CS101 */ public class HallList extends List { public HallList(Hall h, HallList next) { /* Java secretly calls the default constructor List() here. */ this.thing = h; this.rest = next; } /* * The following methods wrap "thing" and "rest" so that users of this * HallList class see objects of type * "Hall" and "HallList", respectively. * * getHall() returns this list element's item (thing), cast as a Hall. * getRestHalls() returns the "rest" of the list, cast as a HallList. */ public Hall getHall() { return (Hall)thing; } public HallList getRestHalls() { return (HallList)rest; } /* * We define toString() for a HallList. * Because we like what List does by way of toString(), we use that, * but we prepend "HallList" so we that we know a HallList when we * see one printed out. * * Note the use of "super.toString()" to call our superclass's (List's) * toString(). */ public String toString() { return "HallList " + super.toString(); } }