Solutions for the In-class Activity on Abstract Data Types, Jan 14, 2002. (c) S. Tanimoto, 2002. The ADT has two parts. First is a general description of the data. Let's represent the data with 5 variables, the first four of them organized as an array or a subscripted variable. x[NORTH] : string x[EAST] : string x[SOUTH] : string x[WEST] : string d: {0,1,2,3,4} 0 means no dummy. Here we've followed each variable by a colon and then an indication of its type. Now let's consider describing the methods for the ADT. In describing the domain and range of each function, we'll use "bridges" to represent the set of possible data instances of the BRIDGE ADT. The symbol "labels" refers to the set {NORTH, EAST, SOUTH, WEST}. The symbol "strings" refers to the set of all possible strings that we might be interested in; these presumably represent people's names. There are four methods given. Here are descriptions for them. The first one, GETPLAYER, is represented is a somewhat more detailed way than the others to emphasize the form of the first argument to the function. That argument represents an instance of the data part of the BRIDGES ADT. GETPLAYER: bridges X labels : strings GETPLAYER: ([x[NORTH],x[EAST],x[SOUTH],x[WEST],d], NORTH) |-> x[NORTH] GETPLAYER: ([x[NORTH],x[EAST],x[SOUTH],x[WEST],d], EAST) |-> x[EAST] GETPLAYER: ([x[NORTH],x[EAST],x[SOUTH],x[WEST],d], SOUTH) |-> x[SOUTH] GETPLAYER: ([x[NORTH],x[EAST],x[SOUTH],x[WEST],d], WEST) |-> x[WEST] If we adopt the convention that x represents all four of its elements, then we can use the following simpler form for describing the mapping. GETPLAYER: ([x,d], NORTH) |-> x[NORTH] etc. SETPLAYER: bridges X labels X strings -> bridges SETPLAYER: ([x[NORTH],x[EAST],x[SOUTH],x[WEST],d], NORTH,s) |-> [s,x[EAST],x[SOUTH],x[WEST],d] etc. GETDUMMY: bridges -> {0,1,2,3,4} GETDUMMY: ([x,d]) |-> d SETDUMMY: bridges X {0,1,2,3,4} SETDUMMY: ([x,d], d') |-> [x,d']