/* +------+ | ILoR |<--------------+ +------+ | / \ | --- | | | -------------------- | | | | +-------+ +------------------+ | | MtLoR | | ConsLoR | | +-------+ +------------------+ | +-------+ +-| Restaurant first | | | | ILoR rest |--+ | +------------------+ v +--------------+ | Restaurant | +--------------+ | String name | | String kind | | int avgPrice | +--------------+ */ // to represent a restaurant in Manhattan class Restaurant{ String name; String kind; int avgPrice; Restaurant(String name, String kind, int avgPrice){ this.name = name; this.kind = kind; this.avgPrice = avgPrice; } } // to represent a list of Manhattan restaurants interface ILoR{} // to represent an empty list of Manhattan restaurants class MtLoR implements ILoR{ MtLoR(){} } // to represent a nonempty list of Manhattan restaurants class ConsLoR implements ILoR{ Restaurant first; ILoR rest; ConsLoR(Restaurant first, ILoR rest){ this.first = first; this.rest = rest; } } class Examples{ Examples(){} // Chinese restaurant Blue Moon with average price per dinner \$15 Restaurant blueMoon = new Restaurant("Blue Moon", "Chinese", 15); // Japanese restaurant Kaimo with average price per dinner \$20 Restaurant kaimo = new Restaurant("Kaimo", "Japanese", 20); // Mexican restaurant Cordita with average price per dinner \$12 Restaurant cordita = new Restaurant("Cordita", "Mexican", 12); // an empty list of restaurants ILoR mtlor = new MtLoR(); // a list with one restaurant ILoR rlistOne = new ConsLoR(this.blueMoon, this.mtlor); // a list with three restaurants ILoR rlist3 = new ConsLoR(this.kaimo, new ConsLoR(this.cordita, this.mtlor)); }