samedi 2 janvier 2016

Idea to implement my program

    #include <iostream>
    #include <vector>
    #include <string>
    using namespace std;
    //Attractionlass---------------------------------------------------------  >Start
    class Attraction
    {
    protected:
    int id;
    string name;
    int typeID;
    public:
    Attraction(int id=0,string name="NULL",int typeID=0):id(id),name(name),typeID(typeID){}
    void setId(int id){this->id=id;}
    void setName(string name){this->name=name;}
    void setTypeID(int typeID){this->typeID=typeID;}
    int getTypeID(){return typeID;}
    int getId(){return id;}
    string getName(){return name;}


};

    //Attraction Class------------------------------------------------------->End
    //Sport Class------------------------------------------------------------>Start
    class Sport :public Attraction
    {
    private:
    int ageLimit;
    public:
    void SetAgeLimit(int age);
    int GetAgeLimit();

    };
    void Sport::SetAgeLimit(int age)
    {
    this->ageLimit = age;
    }
    int Sport::GetAgeLimit()
    {
    return ageLimit;
    }
    //Sport Class------------------------------------------------------------ >End
    //Culture Class---------------------------------------------------------->Start
    class Culture :public Attraction
    {
    private:
    double EntranceFee;
    string placename;
    public:
    Culture(double EntranceFee=0.00,string   placename="NULL"):EntranceFee(EntranceFee),placename(placename){}
    void SetEntryFee(double _price);
    double GetEntryFee();
    };
    void Culture::SetEntryFee(double _price)
    {
    EntranceFee = _price;
    }
    double Culture::GetEntryFee()
   {
    return EntranceFee;
   }
    //Culture Class----------------------------------------------------------->End
    //Shopping Class----------------------------------------------------------  >Start
    class Shopping :public Attraction
    {
    private:
    vector<string*>malls;
    vector<string*>markets;
    string areas;
    int businesshours;
    int contact;

    public:
    Shopping(vector<string*>&malls,vector<string*>&markets,string areas,int businesshours):malls(malls),markets(markets),areas(areas),businesshours(businesshours),contact(contact){}
};

    //Shopping Class---------------------------------------------------------->End
    //City Class-------------------------------------------------------------->Start
    class City
   {
    private:
    int id;
    string name;
    int populations;
    int nooftourist;
    vector<Attraction*>attractions;
    public:
    City(int id,string name,int populations,int nooftourist):id(id),name(name),populations(populations),nooftourist(nooftourist){}
    void setId(int _id);
    void setName(string _name);
    int getId();
    string getName();
    void display(){}
    vector<Attraction*>&getAttractions() { return attractions;}

    };
    void City::setId(int _id)
    {
    id = _id;
    }
    void City::setName(string _name)
    {
    name = _name;
    }

    int City::getId()
   {
    return id;
   }
    string City::getName()
    {
     return name;

     }
     vector<City> cities;

    City* citySelection(bool& hasSelectedCity, bool& toLoop)
    {
    ///do bubble sort
    for (int i = 0 ; i < cities.size() - 1 ; i++)
    {
        for (int j = 0 ; j < cities.size() - 1 ; j++)
        {
            string val1 = cities.at(j).getName();
            string val2 = cities.at(j+1).getName();
            if ( val1 > val2 )
            {
                string temp = val1;
                cities.at(j).setName(val2);
                cities.at(j+1).setName(temp);
            }
        }
    }


    City* targetCity = nullptr;
    for(int i = 0; i < (int)cities.size(); i ++)
    {
        cities.at(i).display();
    }
    cout << "Please select the city by entering the name" << endl;
    cout << "To stop the program enter \"break\"" << endl;
    string input;
    getline(cin, input);
    if(input == "break") toLoop = false;
    for(int i = 0; i < (int)cities.size(); i ++)
    {
        City tempCity = cities.at(i);
        if(tempCity.getName() == input)
        {
            targetCity = &cities.at(i);
            break;
        }
    }
    if(targetCity!=nullptr)
    {
        hasSelectedCity = true;
    }
    return targetCity;
    }


    //City Class-------------------------------------------------------------->End
    int main()

    {
    vector<City*>cities;
    cities.push_back(new City(111,"Kuala Lumpur",80000,4000));
    cities.push_back(new City(112,"Malacca City",30000,1500));
    cities.push_back(new City(113,"Ipoh",70000,3500));

    for (int i = 0; i < cities.size(); i++)
    {
        cout<<i+1<<"."<<cities[i]->getName()<<endl;
    }
    for (int i = 0; i < cities.size(); i++)
    {
        delete cities[i];
    }



    }

this is my program to implement tourism program User Requirements - A city has many attractions and the attractions can be classified into various types. To view the detailed information of an attraction, a tourist will first choose a city from a list of cities displayed in alphabetical order, the type of attraction from a list of attraction types and then the attraction itself. He can also choose a city and then choose from a list of all attractions in the city without choosing a type of attraction. The maximum number of attractions per city must not be fixed in the system. - The user interface has to be user-friendly so that users can navigate with ease. Design a console-based user interface for the system. can i know how to implement in the next step,anyone can give me suggestion?

Aucun commentaire:

Enregistrer un commentaire