#ifndef BATTLESHIP_SOLUTION_H
#define BATTLESHIP_SOLUTION_H

#include <list>
#include <ostream>

#include "Board.h"
#include "Ship.h"

namespace Battleship{

class Solution{
private:
    Board* solved;
    std::list<Ship> ships;

public:
    Solution(Board* board) {solved = new Board(*board);};
    Solution(const Solution& other)
        {solved = new Board(*other.solved); ships = other.ships;};
    ~Solution() { delete solved; };

    void addShips(Ship* ship){ if (ship != NULL)
                               { ships.push_back(*ship);
                                 addShips(ship->getNextShip()); } };

    void addShip(Ship* ship) { ships.push_back(*ship); };

    //Considering this is the only thing that would go in a cpp file otherwise
    //I figured it wouldn't be terrible to put it in here...
    void printSolution(std::ostream& out) {
        ships.sort();
        out << "Solution:" << std::endl;
        for (std::list<Ship>::iterator ship = ships.begin(); ship != ships.end(); ship++)
            ship->printShip(out);
        solved->printBoard(out);
    };

};

};


#endif // BATTLESHIP_SOLUTION_H
