// CSE143 Sp01 Homework 1 Sample Solution // placelist.cpp - implementation of PlaceList data structure and functions // HP 4/01 #include using namespace std; #include "placelist.h" // Make places an empty PlaceList void makePlaceListEmpty(PlaceList &places) { places.size = 0; } // Add place with given name and x, y coordinates to places // Assumption: list is not full void addPlace(PlaceList &places, double x, double y, string name) { places.list[places.size].x = x; places.list[places.size].y = y; places.list[places.size].name = name; places.size++; } // Look for name in places. If found, store coordinates in x, y // and set found = true; if not found set found = false. void findCoordinates(PlaceList &places, string name, double &x, double &y, bool &found) { int k = 0; while (k < places.size && places.list[k].name != name) { k++; } if (k < places.size) { found = true; x = places.list[k].x; y = places.list[k].y; } else { found = false; } }