Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
C++
#include <iostream>
#include <vector>
using namespace std;

int opt_user(){ /*Function to let user choose whether they want to list one or all type of attractions*/

    int input;

    cout<<"\n";
    cout<<"1.List of the all attractions \n";
    cout<<"2.Sports \n";
    cout<<"3.Culture \n";
    cout<<"4.Shopping \n";
    cout<<"Choose the attraction that you want! Enter based on the \n";
    cout<<"number that have listed according to the attraction: \n";
    cin>>input; /*input will be return back to main function*/
    return input;

}

class City{

      string name;
      int id;

public:

      City(int id=0, string name="NULL"):id(id), name(name){}
      void setID(); /*Let user choose city and set id and name*/
      string getName(); /*Return City name*/
      int getID();
};

int City::getID(){

    return id;
}

string City::getName(){

       return name;

}

void City::setID(){ /*A list of cities*/

     cout<<"The list of Cities according to alphabetical form: /n";

     vector<city>city;
     city.push_back(City(01, "Georgetown"));
     city.push_back(City(02, "Kuala Lumpur"));
     city.push_back(City(03, "Malacca"));

     for (int i=0; i<city.size();>     {
          cout<<i+1<<city[i].getName()<<endl; /*Display all the cities*/
     }

     cout<<"Choose a City that you want! Enter based on the number \n";
     cout<<"that have listed according to the City: \n"; /*Let users choose the desired city*/

     int x;
     string selectCity;
     cin>>x;
     this->id = x;
     selectCity = city[x-1].getName(); // User's input will be referred as the city's ID
     this->name = selectCity; /*Set city's name based on user's choice*/

}

class Attraction{

    int typeID;
    int Att_id;

    protected :

               string Att_name;

    public :

               Attraction(int typeID = 0, int Att_id = 0, string Att_name = "NULL"): Att_id(Att_id), typeID(typeID), Att_name(Att_name){}
               string get_attName();
               virtual int display(int id);
};

int Attraction::display(int id){

    cout<<"These are the list of attractions: \n";

    if(id == 1){

        vector<attraction> Georgetown_Att; /*Vector to store all attractions in georgetown*/
        Georgetown_Att.push_back(Attraction(1, 01, "Free Fall & Zip Lining"));
        Georgetown_Att.push_back(Attraction(2, 01, "Tree Swings & Water Park"));
        Georgetown_Att.push_back(Attraction(3, 02, "Khoo Kongsi Temple"));
        Georgetown_Att.push_back(Attraction(4, 02, "Sri Mariamman Temple"));
        Georgetown_Att.push_back(Attraction(5, 02, "St. George's Church"));
        Georgetown_Att.push_back(Attraction(6, 02, "Kapitan Keling Mosque"));
        Georgetown_Att.push_back(Attraction(7, 03, "Prangin Mall"));
        Georgetown_Att.push_back(Attraction(8, 03, "1st Avenue Mall"));

        for(int i = 0; i < Georgetown_Att.size(); i++)
        {
            cout << i+1 << ". " << Georgetown_Att[i].get_attName() << endl;
        }

        int input;
        cout<<"Choose the place you want in the form of the decimal \n";
        cout<<"number that have listed above: \n";
        cin>> input;
        cout << "The place you have choose is: " << Georgetown_Att[input-1].get_attName();  /*Display user's chosen attraction, [ans-1] because vector starts from 0*/
        return input;

    }

    else if(id == 2)
    {
        vector<attraction> KualaLumpur_Att; /*Vector to store all attractions in KL*/
        KualaLumpur_Att.push_back(Attraction(1, 01, "Bukit Jalil Golf"));
        KualaLumpur_Att.push_back(Attraction(2, 01, "Bukit Tabur"));
        KualaLumpur_Att.push_back(Attraction(3, 02, "Chan See Shu Yuen temple"));
        KualaLumpur_Att.push_back(Attraction(4, 02, "Batu Caves"));
        KualaLumpur_Att.push_back(Attraction(5, 02, "Cathedral of St.Mary"));
        KualaLumpur_Att.push_back(Attraction(6, 02, "Masjid Negara Mosque"));
        KualaLumpur_Att.push_back(Attraction(7, 03, "Berjaya Times Square"));
        KualaLumpur_Att.push_back(Attraction(8, 03, "Pavilion Shopping Mall"));

        for(int i = 0; i < KualaLumpur_Att.size(); i++){    /*To display all the attractions in KL*/

            cout << i+1 << "." << KualaLumpur_Att[i].get_attName() << endl;

        }

        int input;
        cout<<"Choose the place you want in the form of the decimal \n";
        cout<<"number that have listed above: \n";
        cin>> input;
        cout << "The place you have choose is: " << KualaLumpur_Att[input-1].get_attName();    /*Display user's choice of attraction,[ans-1] because vector starts from 0*/
        return input;
    }

    else
    {
        vector<attraction> Malacca_Att;
        Malacca_Att.push_back(Attraction(1, 01, "Tiara Melaka Golf & Country Club"));
        Malacca_Att.push_back(Attraction(2, 01, "Wonderland Theme Park "));
        Malacca_Att.push_back(Attraction(3, 02, "Cheng Hoon Teng Temple"));
        Malacca_Att.push_back(Attraction(4, 02, "Sri Poyyatha Vinayagar Moorthi"));
        Malacca_Att.push_back(Attraction(5, 02, "St. Francis Xavier's Church"));
        Malacca_Att.push_back(Attraction(6, 02, "Masjid Tranquerah "));
        Malacca_Att.push_back(Attraction(7, 03, "Mahkota Parade Mall"));
        Malacca_Att.push_back(Attraction(8, 03, "Dataran Pahlawan Megamall"));

        for(int i = 0; i < Malacca_Att.size(); i++)
        {cout << i+1 << ". " << Malacca_Att[i].get_attName() << endl;}    /*Display all attractions Malacca*/

        int input;
        cout<<"Choose the place you want in the form of the decimal \n";
        cout<<"number that have listed above: \n";
        cin>> input;
        cout << "The place you have choose is: " << Malacca_Att[input-1].get_attName();/*[ans-1] because vector starts from 0*/
        return input;
    }

}

class Sports: public Attraction
{

      int MinAge;
      int MaxAge;

public:

      Sports(int Att_id=0, int typeID=0, string Att_name="NULL", int MinAge=0, int MaxAge=0):Attraction(Att_id, typeID, Att_name), MinAge(MinAge), MaxAge(MaxAge){}
      string getSprtname();
      int getAgeMin()
      {
          return MinAge;
      }

      int getAgeMax()
      {
          return MaxAge;
      }
      virtual int display(int id);
};

string Sports::getSprtname()
{
       return Att_name;
}

int Sports::display(int id){

    cout<<"These are the list of Attractions \n";

    if(id==1)
    {
      vector<sports>Georgetown_sports;
      Georgetown_sports.push_back(Sports(1, 01, "Free Fall & Zip Lining",7,60));
      Georgetown_sports.push_back(Sports(2, 01, "Tree Swings & Water Park",7,60));

       for(int i=0; i<georgetown_sports.size();>       {
           cout<<i+1<<"."<<Georgetown_sports[i].getSprtname()<<endl;
       }
       cout<<"Choose the place that you want! Enter based on the \n";
       cout<<"number that have listed according to the attraction: \n";
       int input;
       cin>>input;
       cout<<"The place you have choose: "<<Georgetown_sports[input-1].getSprtname()<<endl
           <<"The Minimum age can enter: "<<Georgetown_sports[input-1].getAgeMin()<<",The Maximum age can enter: "<<Georgetown_sports[input-1].getAgeMax()<<endl;
    }
    else if(id==2)
    {
         vector<sports>KualaLumpur_sports;
         KualaLumpur_sports.push_back(Sports(1, 01, "Bukit Jalil Golf",18,60));
         KualaLumpur_sports.push_back(Sports(2, 01, "Bukit Tabur",18,60));

         for(int i=0; i<kualalumpur_sports.size();>          {
             cout<<i+1<<"."<<KualaLumpur_sports[i].getSprtname()<<endl;
          }
        cout<<"Choose the place that you want! Enter based on the \n";
        cout<<"number that have listed according to the attraction: \n";
        int input;
        cin>>input;
        cout<<"The place you have choose: "<<KualaLumpur_sports[input-1].getSprtname()<<endl
            <<"The Minimum age can enter: "<<KualaLumpur_sports[input-1].getAgeMin()<<",The Maximum age can enter: "<<KualaLumpur_sports[input-1].getAgeMax()<<endl;
    }
    else
    {
         vector<sports>Malacca_sports;
         Malacca_sports.push_back(Sports(1, 01, "Tiara Melaka Golf & Country Club",18,60));
         Malacca_sports.push_back(Sports(2, 01, "Wonderland Theme Park ",7,60));

         for(int i=0; i<malacca_sports.size();>          {
             cout<<i+1<<"."<<Malacca_sports[i].getSprtname()<<endl;
          }
         cout<<"Choose the place that you want! Enter based on the \n";
         cout<<"number that have listed according to the attraction: \n";
         int input;
         cin>>input;
         cout<<"The place you have choose: "<<Malacca_sports[input-1].getSprtname()<<endl
             <<"The Minimum age can enter: "<<Malacca_sports[input-1].getAgeMin()<<",The Maximum age can enter: "<<Malacca_sports[input-1].getAgeMax()<<endl;
    }

}

class Culture:public Attraction
{
      double Entrance_Fee;

 public:

      Culture(int Att_id=0, int typeID=0, string Att_name="NULL", double Entrance_Fee=0):Attraction(Att_id, typeID, Att_name), Entrance_Fee(Entrance_Fee){}
      string getCulname();
      double getEntFee();
      int display(int id);
};

double Culture::getEntFee(){

       return Entrance_Fee;

}

string Culture::getCulname(){

       return Att_name;

}

int Culture::display(int id){

    cout<<"These are the list of Attractions \n";

    if(id==1)
    {
       vector<culture>Georgetown_culture;
       Georgetown_culture.push_back(Culture(3, 02, "Khoo Kongsi Temple",0));
       Georgetown_culture.push_back(Culture(4, 02, "Sri Mariamman Temple",0));
       Georgetown_culture.push_back(Culture(5, 02, "St. George's Church",0));
       Georgetown_culture.push_back(Culture(6, 02, "Kapitan Keling Mosque",0));

       for(int i=0; i<georgetown_culture.size();>       {
           cout<<i+1<<"."<<Georgetown_culture[i].getCulname()<<endl;
       }
       cout<<"Choose the place that you want! Enter based on the \n";
       cout<<"number that have listed according to the attraction: \n";
       int input;
       cin>>input;
       cout<<"The place you have choose: "<<Georgetown_culture[input-1].getCulname()<<endl
           <<"The fees for the entrance: RM" <<Georgetown_culture[input-1].getEntFee()<<endl;
    }
    else if(id==2)
    {
         vector<culture>KualaLumpur_culture;
         KualaLumpur_culture.push_back(Culture(3, 02, "Chan See Shu Yuen temple",0));
         KualaLumpur_culture.push_back(Culture(4, 02, "Batu Caves",0));
         KualaLumpur_culture.push_back(Culture(5, 02, "Cathedral of St.Mary",0));
         KualaLumpur_culture.push_back(Culture(6, 02, "Masjid Negara Mosque",0));

         for(int i=0; i<kualalumpur_culture.size();>         {
             cout<<i+1<<"."<<KualaLumpur_culture[i].getCulname()<<endl;
         }
         cout<<"Choose the place that you want! Enter based on the \n";
         cout<<"number that have listed according to the attraction: \n";
         int input;
         cin>>input;
         cout<<"The place you have choose: "<<KualaLumpur_culture[input-1].getCulname()<<endl
             <<"The fees for the entrance: RM" <<KualaLumpur_culture[input-1].getEntFee()<<endl;
    }
    else
    {
         vector<culture>Malacca_culture;
         Malacca_culture.push_back(Culture(3, 02, "Cheng Hoon Teng Temple",0));
         Malacca_culture.push_back(Culture(4, 02, "Sri Poyyatha Vinayagar Moorthi",0));
         Malacca_culture.push_back(Culture(5, 02, "St. Francis Xavier's Church",0));
         Malacca_culture.push_back(Culture(6, 02, "Masjid Tranquerah ",0));

         for(int i=0; i<malacca_culture.size();>         {
             cout<<i+1<<"."<<Malacca_culture[i].getCulname()<<endl;
         }
         cout<<"Choose the place that you want! Enter based on the \n";
         cout<<"number that have listed according to the attraction: \n";
         int input;
         cin>>input;
         cout<<"The place you have choose: "<<Malacca_culture[input-1].getCulname()<<endl
             <<"The fees for the entrance: RM" << Malacca_culture[input-1].getEntFee()<<endl;
    }
  }

class Shopping:public Attraction{

      string MallName;

public:

      Shopping(int Att_id=0, int typeID=0, string MallName="NULL"):Attraction(Att_id, typeID), MallName(MallName){}
      string getShoppingName();
      int display(int id);

};

string Shopping::getShoppingName(){

       return MallName;

}

int Shopping::display(int id){

    cout<<"These are the list of Attractions \n";

    if(id==1)
    {
       vector<shopping>Georgetown_shopping;
       Georgetown_shopping.push_back(Shopping(6, 02, "Kapitan Keling Mosque"));
       Georgetown_shopping.push_back(Shopping(7, 03, "Prangin Mall"));
       Georgetown_shopping.push_back(Shopping(8, 03, "1st Avenue Mall"));

       for(int i=0; i<georgetown_shopping.size();>       {
           cout<<i+1<<"."<<Georgetown_shopping[i].getShoppingName()<<endl;
       }
       cout<<"Choose the place that you want! Enter based on the \n";
       cout<<"number that have listed according to the attraction: \n";
       int input;
       cin>>input;
       cout<<"The place you have choose: "<<Georgetown_shopping[input-1].getShoppingName()<<endl;
    }
    else if(id==2)
    {
         vector<shopping>KualaLumpur_shopping;
         KualaLumpur_shopping.push_back(Shopping(7, 03, "Berjaya Times Square"));
         KualaLumpur_shopping.push_back(Shopping(8, 03, "Pavilion Shopping Mall"));

       for(int i=0; i<kualalumpur_shopping.size();>       {
           cout<<i+1<<"."<<KualaLumpur_shopping[i].getShoppingName()<<endl;
       }
       cout<<"Choose the place that you want! Enter based on the \n";
       cout<<"number that have listed according to the attraction: \n";
       int input;
       cin>>input;
       cout<<"The place you have choose: "<<KualaLumpur_shopping[input-1].getShoppingName()<<endl;
    }
    else
    {
         vector<shopping>Malacca_shopping;
         Malacca_shopping.push_back(Shopping(7, 03, "Mahkota Parade Mall"));
         Malacca_shopping.push_back(Shopping(8, 03, "Dataran Pahlawan Megamall"));

       for(int i=0; i<malacca_shopping.size();>       {
           cout<<i+1<<"."<<Malacca_shopping[i].getShoppingName()<<endl;
       }
       cout<<"Choose the place that you want! Enter based on the \n";
       cout<<"number that have listed according to the attraction: \n";
       int input;
       cin>>input;
       cout<<"The place you have choose: "<<Malacca_shopping[input-1].getShoppingName()<<endl;
    }

}

int main(){

    cout<<"--------------------------------/n";
    cout<<"|| Welcome To Tourist System  ||/n";
    cout<<"--------------------------------/n";
    cout<<"/n";
    City y;
    y.setID();

    int id = y.getID();
    cout << "\nThe ID of the City: " << id << endl << "The name of the City: " << y.getName() << endl;

    int input = opt_user();

    if(input==1)
    {
        Attraction choice;      /*Create class based on the attraction wanted by the user*/
        choice.display(id);

    }
    else if(input==2) /*List only sports attraction*/
    {
        Sports choice;
        choice.display(id);
    }
    else if(input==3) /*List only Culture attractions in the chosen city*/
    {
        Culture choice;
        choice.display(id);
    }
    else(input==4) /*List all Shopping Malls in the chosen city*/
    {
        Shopping choice;
        choice.display(id);
    }

    cout << "\n\nEnd of program.\n";
    return 0;
}

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 15-Jan-16 1:11am
v6
Comments
[no name] 15-Jan-16 5:27am    
You have a syntay error somewhere in this code. The error message, if you look at it more closely, will tell you in which line. Why do you want us to search it for you in this little code dump?
_Asif_ 15-Jan-16 5:38am    
You probably have missed a ';' somewhere in your code.
Richard MacCutchan 15-Jan-16 6:31am    
Please do not just dump all your code unformatted like this. Edit your question and leave only the lines around the error, indicate exactly which line contains the error (i.e. do not say "on line 445"), and surround the code with <pre> tags, so it is correctly formatted.
Member 12265825 15-Jan-16 6:53am    
well this first time im posting a question seriously i dont know how ,to format it
OriginalGriff 15-Jan-16 7:15am    
I've added the basic formatting for you - that engages the syntax highlighter and preserves your indentation, as you can see.

But that's a lot of code to be looking at to find a small character! :laugh:
So look at your error message, and it'll tell you which line the problem is on - if nothing else it'll give you a file name and a line number, and on many systems CTRL+G will let you enter a line number and go directly to the line.
When you know which line, edit your question, take out all the code, and show us just the relevant line, with a dozen or so lines above and below it for context (sometimes the error is caused by a line a small distance from where it becomes apparent).
And tell us which line!

1 solution

C++
void City::setID(){ /*A list of cities*/
 
     cout<<"The list of Cities according to alphabetical form: /n";
 
     vector<city>city;
     city.push_back(City(01, "Georgetown"));
     city.push_back(City(02, "Kuala Lumpur"));
     city.push_back(City(03, "Malacca"));
 
     for (int i=0; i<city.size();>     {
          cout<<i+1<<city[i].getName()<<endl; /*Display all the cities*/
     }

The for statement third from the bottom is not valid.
 
Share this answer
 
v2
Comments
Jochen Arndt 15-Jan-16 7:34am    
This may be sourced by th CP paste algorithm. I have seen such for loops a few times here (> replaces the 3rd statement and the closing parenthesis).
Member 12265825 15-Jan-16 7:37am    
sorry can u pls tell exactly which part ? please im totally blur due to other isssue
Richard MacCutchan 15-Jan-16 7:40am    
See my response above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900