Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BONUS Implement the method to count the difference types of players (Police, Villagers and Mayor). Return a new string vector with 3 numbers as a

BONUS

Implement the method to count the difference types of players (Police, Villagers and Mayor). Return a new string vector with 3 numbers as a string:

  • First one should be the number of villagers.
  • Second should be number of polices.
  • Third should be number of mayors.
    test result
    Player *c = new Chief("Harry", 61, 100, 5); Player *m = new Mayor("Bienve", 70, 100, 10); Player *p = new Police("Elvin", 60, 100, "ClerkPlace"); Player *v = new Villager("Alberto", 72, 100, "BlackSmithShop"); vector list{c, m, p, v}; vector playersCount = countTypesOfPlayersIn(list); cout << "Size: " << (playersCount.size()) << endl; cout << (playersCount.at(villagerIndex)) << endl; // EXPECTED 1 cout << (playersCount.at(policeIndex)) << endl; // EXPECTED 2 cout << (playersCount.at(mayorIndex)) << endl; // EXPECTED 1
    Size: 3 1 2 1

#include "VillageB.cpp"

/* * BONUS: * * Implement the method to count the difference types of Players. * Return a new string array with 3 numbers as a string. * First one would be the number of Villagers. * Second would be number of Polices. * Third would be number of Mayors. * (Hint: Use the method to_string(...) to change from a int to a string) */

static vector countTypesOfPlayersIn(vector &list) { //Implement here!

return vector{}; //Dummy Return }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions