Question
Implement CandidateQueue.cpp In CandidateQueue.cpp only implement the functions void CandidateQueue::push_cadidate(Candidate* p) and string CandidateQueue::Exist(string r) DO NOT TOUCH this function ->CandidateQueue::CandidateQueue() For the function void
Implement CandidateQueue.cpp
In CandidateQueue.cpp only implement the functions
void CandidateQueue::push_cadidate(Candidate* p)
and string CandidateQueue::Exist(string r)
DO NOT TOUCH this function ->CandidateQueue::CandidateQueue()
For the function void push_cadidate(Candidate* p); // Pushes a pointer to a candidate onto the back of the line (the info of Node is a pointer to Candidate :D ). // update head, tail and count
and for string Exist(string role);
// Check the line and see if there is any candidate with the give role in the line (the line is implemented in linked list) // If there is, return the name of that candidate // If no such candidate exists, returns "".
MUST BE IN C++
source.cpp file
/* In this program, we have a line of candidates, some are developer and some are designer. When we want to create a team, we need one deisgner and one developer. The candidates are all standing in the line. */ #include#include "CandidateQueue.h" using namespace std; int main() { // Variables used for testing Candidate daniela("Daniela", "Developer"); Candidate hector("Hector", "Salesman"); Candidate berta("Berta", "Designer"); Candidate hugo("Hugo", "Salesman"); Candidate bernardo("Bernardo", "Designer"); Candidate daria("Daria", "Developer"); CandidateQueue q; q.push_cadidate(&daniela); q.push_cadidate(&hector); q.push_cadidate(&berta); q.push_cadidate(&hugo); q.push_cadidate(&bernardo); q.push_cadidate(&daria); /* The output should be There is a salesman in the line. First one called Hector There is a designer in the line. First one called Berta There is no one with marketing specialty *********** */ string c = q.Exist("Salesman"); if (c == "") cout << "There is no one with salesman specialty "; else cout << "There is a salesman in the line. First one called " << c << endl; c = q.Exist("Designer"); if (c == "") cout << "There is no one with designer specialty "; else cout << "There is a designer in the line. First one called " << c << endl; c = q.Exist("Marketing"); if (c == "") cout << "There is no one with marketing specialty "< CandidateQueue.h FILE
#pragma once #include "Candidate.h" class CandidateQueue { public: class Node { public: Candidate* c; Node* next; }; // Constructor: initialize head, tail and count CandidateQueue(); // Pushes a pointer to a candidate onto the back of the line (the info of Node is a pointer to Candidate :D ). // update head, tail and count void push_cadidate(Candidate *p); // Check the line and see if there is any candidate with the give role in the line (the line is implemented in linked list) // If there is, return the name of that candidate // If no such candidate exists, returns "". string Exist(string role); private: Node* head; Node* tail; int count; };CandidateQueue.cpp file
#include "CandidateQueue.h"
#include
using namespace std;
CandidateQueue::CandidateQueue()
{
count = 0;
head = nullptr;
tail = nullptr;
}
void CandidateQueue::push_cadidate(Candidate* p) {
//To DO
}
string CandidateQueue::Exist(string r) {
//To DO
}
Candidate.h
#pragma once #includeusing namespace std; class Candidate { public: // Initializes a player with the given name and role. role is either developer or designer Candidate(string name, string role); // Returns the name of the player string name(); // Returns the role of the player string role(); private: string _name; string _role; }; Candidate.cpp #include "Candidate.h" Candidate::Candidate(string name, string role) { _name = name; _role = role; } string Candidate::name() { return _name; } string Candidate::role() { return _role; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started