hello,

while studying for our short tests, our tutor gave us this problem to complete telling us that if we could do this it would be great. problem is we havnt quiet covered the syllabus yet and yet its coming in the papers and we are xpected to learn on our own.

with a partially completed projet, we are supposed to finish it where by the user enters a country name, its region, economy, tourist arrivals, tourism rankings. together with this we are supposed to enter the name of the cities and state whether it is the capital city or not, the tourist arrival of the particular city, and if u can travel there by air.

i've done a lil bit but im really stuck.

find attached a document outlining the major implementations to be done and a graphical view of the linked lists. bt im truely confused til now. i cant seem to enter the data. templetes are used also.

can some1 please tel me what and how to do pliz?

here's what i've done so far. the main program and the country class implementation has to be completed. also in country class, this piece of code NODE<city> * _city, what do i have to do with this?

thanks


#include <iostream.h>
#include <stdlib.h>
#include <string>
using namespace std;


//------------------------------------------------------------------------

template <class T>
struct NODE {
NODE<T> *pNext;
NODE<T> *pPrev;
T nData;
};

template <class T>
void AppendNode(NODE<T> * pNode, NODE<T> **pHead, NODE<T> **pTail);

template <class T>
void InsertNode(NODE<T> *pNode, NODE<T> *pAfter, NODE<T> **pTail);

template <class T>
void InsertNodeAt(NODE<T> *pNode, NODE<T> *pAfter, NODE<T> **pHead);

template <class T>
void RemoveNode(NODE<T> *pNode, NODE<T> **pHead, NODE<T> **pTail);

template <class T>
void DeleteAllNodes(NODE<T> **pHead, NODE<T> **pTail);


template <class T>
void AppendNode(NODE<T> * pNode, NODE<T> **pHead, NODE<T> **pTail)
{
if (*pHead == NULL) {
*pHead = pNode;
pNode->pPrev = NULL;
}
else {
(*pTail)->pNext = pNode;
pNode->pPrev = *pTail;
}
*pTail = pNode;
pNode->pNext = NULL;
}

// Inserts a node into the list after pAfter
template <class T>
void InsertNode(NODE<T> *pNode, NODE<T> *pAfter, NODE<T> **pTail)
{
pNode->pNext = pAfter->pNext;
pNode->pPrev = pAfter;

if (pAfter->pNext != NULL)
pAfter->pNext->pPrev = pNode;
else
*pTail = pNode;

pAfter->pNext = pNode;
}

template <class T>
void InsertNodeAt(NODE<T> *pNode, NODE<T> *pAt, NODE<T> **pHead)
{
pNode->pNext = pAt;
pNode->pPrev = pAt->pPrev;


if (pAt->pPrev == NULL) //head
*pHead = pNode;
else
pAt->pPrev->pNext = pNode;

pAt->pPrev = pNode;
}

// Removes the specified node from the list
template <class T>
void RemoveNode(NODE<T> *pNode, NODE<T> **pHead, NODE<T> **pTail)
{
if (pNode->pPrev == NULL)
*pHead = pNode->pNext;

else
pNode->pPrev->pNext = pNode->pNext;

if (pNode->pNext == NULL)
*pTail = pNode->pPrev;

else
pNode->pNext->pPrev = pNode->pPrev;

delete pNode;
}

// Deletes the entire list
template <class T>
void DeleteAllNodes(NODE<T> **pHead, NODE<T> **pTail)
{
while (*pHead != NULL)
RemoveNode(*pHead, pHead, pTail);
}

//-------------------------------------------------------------------------



//------------------------------------------------------------------------------

class city{
public:
city();
~city();
string getName() const;
void setName(string name);
bool getIscapital() const;
void setIscapital(bool iscapital);
unsigned int getTourist_arrivals() const;
void setTourist_arrivals(unsigned int tourist_arrivals);
bool getTravel_by_air() const;
void setTravel_by_air(bool travel_by_air);
private:
string name;
bool iscapital;
unsigned int tourist_arrivals;
bool travel_by_air;
};

city::city() {
// TODO Auto-generated constructor stub

}

city::~city() {
// TODO Auto-generated destructor stub
}

string city::getName() const
{
return name;
}

void city::setName(string name)
{
this->name = name;
}

bool city::getIscapital() const
{
return iscapital;
}

void city::setIscapital(bool iscapital)
{
this->iscapital = iscapital;
}

unsigned int city::getTourist_arrivals() const
{
return tourist_arrivals;
}

void city::setTourist_arrivals(unsigned int tourist_arrivals)
{
this->tourist_arrivals = tourist_arrivals;
}

bool city::getTravel_by_air() const
{
return travel_by_air;
}

void city::setTravel_by_air(bool travel_by_air)
{
this->travel_by_air = travel_by_air;
}

//-----------------------------------------------------------------------------

class country {
public:
country();
virtual ~country();
string getName() const;
void setName(string name);
string getRegion() const;
void setRegion(string region);
string getEconomy() const;
void setEconomy(string economy);
unsigned int getTourist_arrivals() const;
void setTourist_arrivals(unsigned int tourist_arrivals);
int getTourism_ranking() const;
void setTourism_ranking(int tourism_ranking);
NODE<city> * _city;

private:
string name;
string region;
string economy;
unsigned int tourist_arrivals;
int tourism_ranking;

};


country::country() {
// TODO Auto-generated constructor stub

}

country::~country() {
// TODO Auto-generated destructor stub
}


string country::getName() const
{
return name;
}

void country::setName(string name)
{
this->name = name;
}

string country::getRegion() const
{
return region;
}

void country::setRegion(string region)
{
this->region = region;
}

string country::getEconomy() const
{
return economy;
}

void country::setEconomy(string economy)
{
this->economy = economy;
}

unsigned int country::getTourist_arrivals() const
{
return tourist_arrivals;
}

void country::setTourist_arrivals(unsigned int tourist_arrivals)
{
this->tourist_arrivals = tourist_arrivals;
}

int country:: getTourism_ranking()const
{
return tourism_ranking;
}

void country::setTourism_ranking(int tourism_ranking)
{
this->tourism_ranking = tourism_ranking;
}

//-----------------------------------------------------------------------------


int main(){

country details;


string value;
cout <<"enter country name ?"<<endl ;
cin >> value;
details.setName(value);
cout<<endl;

string reg;
cout<<"region?"<<endl;
cin>>reg;
details.setRegion(reg);
cout<<endl;

string eco;
cout<<"economy?"<<endl;
cin>>eco;
details.setEconomy(eco);
cout<<endl;

unsigned int ari;
cout<< "tourist arrivals"<<endl;
cin>>ari;
details.setTourist_arrivals(ari);
cout<<endl;

int rank;
cout<< "tourism ranking"<<endl;
cin>>rank;
details.setTourism_ranking(rank);
cout<<endl;

cout<<" country name: "<<details.getName()<<endl;
cout<<" region: "<<details.getRegion()<<endl;
cout<<" economy: "<<details.getEconomy()<<endl;
cout<<" tourist arrivals: "<<details.getTourist_arrivals()<<endl;
cout<<" tourism ranking: "<<details.getTourism_ranking()<<endl<<endl;



system("pause");
return 0;
}