Santa Claus allegedly keeps lists of those who are naughty and those who are nice. On the naughty list are the names of those who will get coal in their stockings and therefore no gifts. On the nice list are those who will receive gifts. Each object in on the nice list contains child's name (string) and a list of that child's list of gifts (an instance of ADT list).Design an ADT for the objects in the nice list. Each ADT operation by stating its purpose, describing its parameters and writing preconditions and post conditions
Name the program giftlist.cpp. Make sure the following requirements are met.
Remember to upload all files before submitting.
Example run of program
name for nice list: greg
add gifts for greg
gift: legos
gift: cookie
gift:
name for nice list: bob
add gifts for bob
gift: monopoly
gift: candy cane
gift:
name for nice list: alice
add gifts for alice
gift: dress
gift:
name for nice list: tim
add gifts for tim
gift: superman comic
gift: car
gift: pony
gift:
name for nice list:
The list contains
greg legos cookie
bob monopoly candy cane
alice dress
tim superman comic car pony
ANSWER:
#include <iostream>
#include <cstdlib>
using namespace std;
class Gifts // Implementing list in Queue style
{
private:
int currentsize, arraysize, first, last;
string *queueArray;
public:
Gifts(int s = 100); // Constructor
~Gifts(); // Destructor
bool enqueue(string); // Add to end
bool dequeue(); // Remove from front
string front() const; // Get value at front
bool isEmpty() const { return currentsize <= 0;
}
bool Fisull() const { return currentsize >= arraysize; }
int Size() const { return currentsize; }
friend ostream & operator << (ostream &, Gifts
&);
};
Gifts::Gifts(int s) // Constructor
{
queueArray = new string[s]; // Dynamically allocate array of
gifts
arraysize = s;
currentsize = 0;
first = 0;
last = -1;
}
Gifts::~Gifts() // Destructor
{
delete[] queueArray; // Deallocate array
}
bool Gifts::enqueue(string value)
{
if (currentsize >= arraysize) return false;
last = (last + 1) % arraysize;
queueArray[last] = value;
currentsize++;
return true;
}
bool Gifts::dequeue()
{
if (currentsize < 1) return false;
first = (first + 1) % arraysize;
currentsize--;
return true;
}
string Gifts::front() const
{
if (currentsize < 1)
{
cout << "Cannot take front of empty queue!\n";
exit(0);
}
return queueArray[first];
}
ostream & operator << (ostream &of, Gifts
&cq)
{
of << "Gifts are: ";
int index = cq.first;
int count = 0;
while (count < cq.Size())
{
of << cq.queueArray[index] << " ";
index = (index + 1) % cq.arraysize;
count ++;
}
cout<<endl;
}
//--------------------------Nice class
definition--------------------------------------//
struct NiceChild{
string name;
Gifts giftList;
};
class Nice // Implementing list in Queue style
{
private:
int currentsize, arraysize, first, last;
NiceChild *nc;
public:
Nice(int s = 100); // Constructor
~Nice(); // Destructor
bool enqueue(NiceChild); // Add to end
bool dequeue(); // Remove from front
NiceChild front() const; // Get value at front
bool isEmpty() const { return currentsize <= 0;
}
bool Fisull() const { return currentsize >= arraysize; }
int Size() const { return currentsize; }
friend ostream & operator << (ostream &, Nice
&);
};
Nice::Nice(int s) // Constructor
{
nc = new NiceChild[s]; // Dynamically allocate array of nice
children
arraysize = s;
currentsize = 0;
first = 0;
last = -1;
}
Nice::~Nice() // Destructor
{
delete[] nc; // Deallocate array
}
bool Nice::enqueue(NiceChild value)
{
if (currentsize >= arraysize) return false;
last = (last + 1) % arraysize;
nc[last] = value;
currentsize++;
return true;
}
bool Nice::dequeue()
{
if (currentsize < 1) return false;
first = (first + 1) % arraysize;
currentsize--;
return true;
}
NiceChild Nice::front() const
{
if (currentsize < 1)
{
cout << "Cannot take front of empty queue!\n";
exit(0);
}
return nc[first];
}
ostream & operator << (ostream &of, Nice
&cq)
{
of << "Name in nice list: ";
int index = cq.first;
int count = 0;
while (count < cq.Size())
{
of << cq.nc[index].name << " \n";
cout<<cq.nc[index].giftList;
index = (index + 1) % cq.arraysize;
count ++;
}
}
int main(int argc, char ** argv)
{
int iGifts=0, iCounter, iNiceChildCount=100;
string sName, sGift;
Nice niceList(iNiceChildCount);
NiceChild nc;
cout<<"Enter name for nice list: ";
cin>> sName;
while(sName.length() > 0){ // Check if the string is empty
cout<<"\nEnter number of gifts: ";
cin>> iGifts;
Gifts gifts(iGifts);
for(iCounter=0;iCounter<iGifts;iCounter++){
cout<<"Enter gift for "<<sName<<": ";
cin>> sGift;
gifts.enqueue(sGift);
}
nc.name = sName;
nc.giftList = gifts;
niceList.enqueue(nc);
sName = "";
cout<<"Enter name: ";
cin >> sName;
}
cout<< niceList.Size();
for(iCounter=0;iCounter<niceList.Size();iCounter++){
cout<< niceList;
}
}

Santa Claus allegedly keeps lists of those who are naughty and those who are nice. On...
C++ Santa Claus allegedly keeps lists of those who are naughty and those who are nice. On the naughty list are the names of those who will get coal in their stockings. On the nice list are those who will receive gifts. Each object in this list contains a name (a string) and a list of that person’s gifts (an instance of an ADT list). Design an ADT for the objects in the nice list. Specify each ADT operation by...
Santa Claus needs to automate the compiling of the naughty and nice lists. Your program will read in each child’s name and their count of major and minor good deeds and their major and minor bad deeds. With that information, compute an overall score and determine if they go on the naughty or nice list. Major good deeds might be something like shoveling the walk and driveway for the chronologically challenged lady down the street, a minor good deed would...