Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description Object Oriented Gift Exchange List Many companies hold a holiday gift exchange and randomly select partners from the employees that chose to participate. This
Description Object Oriented Gift Exchange List Many companies hold a holiday gift exchange and randomly select partners from the employees that chose to participate. This assignment will have you build objects needed to implement a gift exchange list, then randomly assign the partners in the list. In order to accomplish this, you will build a list that holds participant objects. Properties forthe list and participant objects will be set and manipulated through their public member functions. Objects Specifications Note: Create separate header and cpp les for each object class dened below below. Participant List Object a Private Member Variables (Private Properties) 0 Vector that contains pointers to Participant objects The rst part of the denition is: vector 0 Current Index - Integer. Used In the Next function a Member Functions (Methods) 0 AssignPartners I No Params I Randomly assigns partners to all of the participants 0 Randomly select a Partner for each person In the list 0 If the randomly selected person has been previously selected, pick a different person. If not, assign them and set their Selected property to true. a A person cannot have themselves as the Partner 0 AddParticipant I Accepts a pointer to a Participant Object I Adds a participant to the list I Does not return a value 0 GetNext - Returns a pointer to the next Participant object from the list I Use the Current Index member variable to retrieve the next participant from the list I Increment the Current Index after retrieving the participant. I If the Current Index is past the end of the vector. return a null pointer. a Do not increment the Current Index. 0 GetPartner I Accepts the location of a partner as an integer I Check to make sure the location passed is not equal to -1 I Returns a pointer to a Participant Object at the specied location o Create a Destructor forthe Participant List I Destroy all of the participant pointers in the vector Participant Object o Private Member Variables (Private Properties) 0 Selected - Boolean - Default value = false 0 Partner Location - Default value = -1 0 First - String 0 Last - String 0 Member Functions (Methods) 0 Default Constructor I Params - two strings 0 All params have a default values. making this the default constructor e First a Last I Sat 0 Partner Location = -1 0 Selected = False 0 Selected - Returns a boolean value indicating whether this participant has been selected as a pannen I Set I Accepts a bool value I Get 0 Returns True if already selected 0 Returns False if not selected yet 0 Partner Location I Set 0 Accepts an int value which is the array index where the partner is located. I Get I Returns the Partner location as an Integer, or -1 if no partner is assigned. 0 GetFirstName o GetLastName o GetFuIIName - Returns a string with the participants name formatted as specied below I Returns the participants name in this format: Last name. First Name Example: Anaya, Dan Instructions What to do 1. Create the two class denitions shown above a. Each class must have a header le Contains the class member function denitions, but not the code to implement the member functions b. Each class must have a CPP file Contains the code to implement the member functions 2. In the Main() function for your project a. Create a pointer to a ParticipantList - You may only have one Participant List in your program. b. Create a single Participant pointer named aPerson You may only have one in your program. c. Ask the user how many participants they would like to create. Note: There must be an even number of participants for this program to work! d. Using a loop. dynamically create participants using the aPerson participant pointer created earlier. i. For each participant. prompt the user fora First and Last name ii. Store the information in the aPerson participant pointer iii. Add the aPsrson participant pointer to the ParticipantList using the AddPartlcipant member function. 3. After all participants have been added to the list. invoke the ParticipantList AssignPartners member function. The function will randomly assign partners for all of the participants. 4. Use a While Loop to display the results following the sample output shown in Figure 1 a. In the loop, use the ParticipantList GetNext member function to retrieve the next participant. b. Use the GetFullName member function to retrieve the name 0. Continue the loop until the participant pointer returned is a null pointer. Before ending your program, destroy the Participant List. Compile and test your application. If there are errors, x them before submitting your work. 7. Zip compress your les and submit before the deadline. 5339' Figure 1
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