Question: Please someone could help me Create a C++ PROGRAM that runs with no failed tests provided in main.cpp and match the definitions provided in lfgqueue.h
Please someone could help me Create a C++ PROGRAM that runs with no failed tests provided in main.cpp and match the definitions provided in lfgqueue.h
Help me plssss. Everytime i ask this question, someone sends a code that generates a double memory leak or does not implement the function in the LFGQueue class :(. Please help me.
Remember this are the functions in the .h file because everyone keeps forgeting about implementing bool front_group(Player** group);
1.-LFGQueue(); 2.-int size(); 3.-void push_player(Player* p); 4.-Player* front_player(Player::Role r); 5.-void pop_player(Player::Role r); 6.- bool front_group(Player** group); 7.-void pop_group();
In many multiplayer online games, theres a looking for group feature for being automatically matched with other players. Such a feature behaves like a queue: players join the queue and removed in complete groups, and players who join the queue first are the first to be grouped. Here youll implement a looking-for-group queue for a game where players can be one of three roles (Defender, Hunter, and Bard) and each group consists of one Defender, one Hunter, and one Bard.
YOU CAN ONLY CHANGE lfgqueue.cpp file. Do not change anything else

Create a new C++ source file named lfgqueue.cpp that implements the LFGQueue class
declared in lfgqueue.h such that lfqueue.cpp and the provided files compile into a program that runs with no failed tests.
The following files have been given and are not to be changed:
-------------ifgqueue.h----------------------
#ifndef LFGQUEUE_H #define LFGQUEUE_H
#include "player.h" #include
class LFGQueue { public: // Constructs a new empty queue with capacity for 100 players LFGQueue();
// Returns the number of players in the queue. int size();
// Adds a (pointer to a) player to the back of the queue. // If there is no room for the new player it doubles the // capacity of the queue before adding the player void push_player(Player* p);
// Returns a pointer to the frontmost player // with the specified role. If no such player // exists, returns nullptr. Player* front_player(Player::Role r);
// Removes the frontmost player with the // specified role. If no such player exists // does nothing. void pop_player(Player::Role r);
// Returns whether the queue contains a complete group // (a Defender, a Hunter, and a Bard). // // If the queue contains a complete group, the method // sets the first three elements of the array parameter // equal to the addresses of the frontmost: // 1. Defender (index 0) // 2. Hunter (index 1) // 3. Bard (index 2) bool front_group(Player** group);
// Removes the frontmost Defender, Hunter, // and Bard from the queue. If some role // has no player with that role, then // no players are removed. void pop_group();
private: Player** players; // Pointer to the queue (dynamic array) int count; // Total quantity of players in the queue int capacity;
// Current capacity of the queue
// IMPORTANT: the queue MUST be implemented assuming FRONT is at index 0 };
#endif
----------main.cpp------
#include#include #include #include "lfgqueue.h" using namespace std; inline void _test(const char* expression, const char* file, int line) { cerr name() == oss.str()); oss.str(""); oss name() == oss.str()); oss.str(""); oss name() == oss.str()); q.pop_group(); test(q.size() == 999 - 3 * (i+1)); } test(q.size() == 0); test(!q.front_group(group)); for (int i = 0; i
--------------------------player.cpp----------------
#include "player.h"
// Initializes a player with the given name and role Player :: Player(string name, Role role) { _name = name; _role = role; }
// Returns the name of the player string Player :: name() { return _name; }
// Returns the role of the player Player::Role Player :: role() { return _role; }
--------------------player.h------------------
#ifndef PLAYER_H #define PLAYER_H
#include
using namespace std;
class Player { public: // This works like a custom type with just three values. // Outside of Player methods, reference them like: // "if (p->role == Player::Defender)", etc. enum Role {Defender, Hunter, Bard};
// Initializes a player with the given name and role Player(string name, Role role);
// Returns the name of the player string name(); // Returns the role of the player Role role(); private: string _name; Role _role; };
#endif
Player objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
