1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#pragma once
#include <memory>
#include <string>
class ItemSpec {
public:
enum class continent { ANY, Africa, Europe, Asia, Australia, Eurasia, North_America, Latin_America };
ItemSpec() : _country(""), _rating(0), _continent(ItemSpec::continent::ANY) { }
ItemSpec(std::string const& country, ItemSpec::continent continent, int rating);
ItemSpec(ItemSpec::continent continent) : _country(""), _rating(0), _continent(continent) { }
virtual bool matches(const ItemSpec & item_spec) const { return true; }
std::string get_country() const { return _country; }
continent get_Continent() const { return _continent; }
int get_rating() const { return _rating; }
virtual bool get_visited() const { return false; }
virtual float get_height() const { return 0; }
virtual void send_to(std::ostream& os) const { /* Does nothing */ }
std::string get_continent() const
{
const char *mode[] = { "ANY", "Africa", "Europe", "Asia", "Australia", "Eurasia", "North_America", "South_America" };
return mode[static_cast<size_t>(_continent)];
}
protected:
std::string _country;
continent _continent;
int _rating;
};
//std::ostream& operator<<(std::ostream& os, ItemSpec::continent t);
std::ostream & operator<<(std::ostream & os, ItemSpec::continent t)
{
switch (t)
{
case ItemSpec::continent::Africa: os << "Africa"; break;
case ItemSpec::continent::Asia: os << "Asia"; break;
case ItemSpec::continent::Australia: os << "Australia"; break;
case ItemSpec::continent::Eurasia: os << "Eurasia"; break;
case ItemSpec::continent::Europe: os << "Europe"; break;
case ItemSpec::continent::Latin_America: os << "South America"; break;
case ItemSpec::continent::North_America: os << "North America"; break;
default: os << "Unknown"; break;
}
return os;
}
//std::ostream & operator<<(std::ostream & os, const TownSpec & spec);
std::ostream & operator<<(std::ostream & os, const ItemSpec & spec)
{
spec.send_to(os);
return os;
}
ItemSpec::ItemSpec(std::string const& country, ItemSpec::continent continent, int rating)
{
_country = country;
_continent = continent;
_rating = rating;
}
|