// Given kod för uppgift 1 - Piratkartor #include #include // Du kan ändra includes för att passa ditt val av filnamn, men tänk på // att inkludera två gånger så att du kontrollerar att din include // guard fungerar som den ska #include "island_map.h" #include "island_map.h" // Given kod för att skriva ut kartan { // width och height förutsätts här vara bredd och höjd på kartan // os förutsätts vara utströmmen att skriva kartan till os << std::setfill('~') << std::endl; os << "+" << std::setw(width + 1) << "+" << std::endl; for (int i {}; i < height; ++i) { os << "|"; for (int j {}; j < width; ++j) { // lämpligt funktionsanrop med parametrar (j, i, os) } os << "|" << std::endl; } os << "+" << std::setw(width + 1) << "+" << std::setfill(' ') << std::endl; } // OBS! Ändringar i main kan leda till Komplettering // Det ingår i uppgiften att skriva klassen så att main går att kompilera utan varningar eller fel int main() { Map north_map{10, 20}; north_map.add_island({1,9}); north_map.add_island({0,3}); north_map.add_island({3,1}); north_map.add_island({5,15}); north_map.add_island({15,7}); // out of bounds (15>10 but that's ok) std::cout << north_map; Map south_map{20, 10};; south_map.add_island({7,6}); south_map.add_island({8,8}); south_map.add_island({5,9}); south_map.add_island({13,8}); south_map.add_island({3,19}); // out of bounds (19>10 but that's ok) std::cout << south_map; Map const cloned_map{north_map}; Map const complete_map { cloned_map + south_map }; // use max width and max height std::cout << complete_map; // previously out of bounds island will show now! }