Item + new($name, $points) + getName, getPoints Room + new($name, $description, $room_north, $room_south, $room_west, $room_east, @item) + addItem($item), removeItem($name) + getName, getDescription, ... Map + load($filename) + initialize_rooms($filename) + getRoom($name), getRoom($row, $col) Player + new($name, $current_room, $points) + move($direction) + take($item_name) + drop($item_name) # perhaps a good addition + throw_away($item_name) # perhaps also a good addition + look($item_name) + getName, getCurrentRoom, getPoints, getInventory : returns @item Game + new($map, %player_name_and_current_rooms) + quit + getMap, getPlayer : return @player #### my %player_names_and_start_room_names = ( bob => 'dark_hall', jay => 'forest', ); $map = Map->load($map_filename); $map->initialize_rooms($room_filename); $game->new($map, %player_names...); #### while (1) { print "You are in room", $player->getCurrentRoom->getName; print "There are several items in this room:", map {$_->getName}, $player->getCurrentRoom->getItems; print "In the north, there is ", $player->getCurrentRoom->getNorthRoom->getName; ... print "Choose: move (N),(S),(W),(E); (T)ake, (L)ook, (I)nventory, (Q)uit"; my $action = read_action; if ($action =~ /[NSWE]/) { $player->move($action) or print "Couldn't move to $action"; } elsif ($action =~ /[TL]/) { my $item = read_item; if ($action eq 'T') { $player->take($item) or print "Couldn't take $item"; } else { print $player->getCurrentRoom->getItem($item)->getDescription || "No description available"; } } }