#include #include #include #include #include "superhero.h" #include "team.h" using namespace std; int main() { // ------------------------------------------------------- // IMPORTANT: DO NOT MODIFY ANY OF THE PROVIDED TEST CASES // ------------------------------------------------------- // reading from an input string stream is similar to reading from an // input file stream. the special character \n inserts a newline, // just like std::endl. here we prepare the input stream: istringstream istr; istr.str(string("Elastigirl Zoe Flexible\n") + string("Falcon Roland Flying\n") + string("Shadow Violet Invisible\n") + string("Gazerbeam Pierce Laser\n") + string("Flame Fiona Fire\n") + string("Lumberman Jack Wood\n") + string("Aquawoman Marie Water\n") + string("Dash Aaron Speed\n")); // create a bunch of superheroes Superhero a,b,c,d,e,f,g,h; // initialize them from an input string stream istr >> a >> b >> c >> d >> e >> f >> g >> h; // access information about the superheroes assert (a.getName() == "Elastigirl"); assert (b.getPower() == "Flying"); assert (c.getName() == "Shadow"); assert (d.getPower() == "Laser"); // output the superheroes to an output string stream ostringstream ostr; ostr.str(""); ostr << a << b; // here we verify that the output is correct assert (ostr.str() == string("Superhero Elastigirl has power Flexible\n") + string("Superhero Falcon has power Flying\n")); // superheroes start out good, but can be corrupted (negated) -b; -c; -c; assert (a.isGood()); assert (!b.isGood()); assert (c.isGood()); // the output stringstream is cleared before reuse ostr.str(""); ostr << b << c; assert (ostr.str() == string("Supervillain Falcon has power Flying\n") + string("Superhero Shadow has power Invisible\n")); // there is no public accessor for a superhero's true identity // but we can try to guess a superheroe's true identity assert (a == "Zoe"); assert (!(b == "Bob")); assert (c != "Lilly"); assert (!(d != "Pierce")); // superhero powers can be compared. note that this property is *not* transitive! assert (e > f); // fire beats wood assert (f > g); // wood beats water assert (g > e); // water beats fire // superheroes can form teams Team team1; team1 += a; team1 += b; Team team2 = c + d; // team names are a combination of the member's true identities assert (team1.getName() == "Zoro"); assert (team2.getName() == "Vipi"); // Teams can merge Team team3 = team1 + team2; assert (team3.getName() == "Zorovipi"); // note that this is the same as: Team team4 = (a + b) + (c + d); assert (team4.getName() == "Zorovipi"); // and this: Team team5 = e + f + g + h; assert (team5.getName() == "Fijamara"); // is the same as: Team team6 = ((e + f) + g) + h; assert (team6.getName() == "Fijamara"); // Superheroes can leave teams team3 -= a; assert (team3.getName() == "Rovipi"); team4 -= b; assert (team4.getName() == "Zovipi"); // the most recently added member is always at the end of the name team4 += b; assert (team4.getName() == "Zovipiro"); // ------------------------------------------- // ADD YOUR OWN TEST CASES OF THE BASIC SYSTEM // ------------------------------------------- // ----------------------------------------------------------------- // ADD TEST CASES TO DEMONSTRATE YOUR NEW FEATURES (for extra credit // ----------------------------------------------------------------- cout << "Passed all test cases." << endl; return 0; }