Suggestion

Seriously i am doing my oop tourism project with 5 classes which is city,attraction ,cultute, shopping, sports, in sports i have no idea to implement function and attributes, anyone can give me suggestion
What do you mean you have no idea? You told me you know how to implement functions and attributes, but that you didnt know what you had to implement.

But how are we supposed to know? You are the one with the project. You're the one with the instructions, what exactly do you want from us? We can't help you with what you need to implement since we do not know the instructions of the project you're working on.

If for some reason there was a misunderstanding and you do not know how to implement functions and attributes, look again at the private message I sent you with multiple links to tutorials about functions,attributes and classes.

Edit: Things you can have in a City class could be population, how big it is, etc.

If english is not you're first language please consider using Google translate so you can form your question a little bit better because it's the third time I see you ask it and it still makes little sense.

Hopefully we'll be able to help you somehow :)
Last edited on
other than population,what attribute can put inside?
As TarikNaej said, please give some details of the assignment. Reading this thread I have no idea what you might need to represent for sports, or what operations you might need to do. Do you need to show teams? Their schedules? Where they play? Their records? Professional, college, high school or pee-wee teams?
Based on the class diagram given above, implement a console-based tourist information system providing information about tourist attractions in various cities. The administrator of the system will specify the necessary information and tourists will view the information by choosing from a text-based menu. A search feature is not required by this system.
Before implementing the system, do an analysis to identify all the necessary data members and member functions required by each class taking into consideration special functions like constructors and copy constructors. Add more classes, for example, for new types of attractions, to your design if needed to make it a comprehensive tourist information system. You may also add more features to the system beyond the user requirements listed below. Modify the given class diagram accordingly.
Milestone 1
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.
Technical Requirements
- For Milestone 1 only, the data of cities, types of attractions and attractions can be hardcoded in the source code.
- The system should use containers and algorithms in the standard template library where appropriate.
- Your code must be compiled with only the standard g++ libraries. Do not use third-party libraries you might find online elsewhere.
Okay. Now go through the requirements and start sketching out what you need. It's difficult without seeing the class diagram but given what you have, here's how I'd approach it:
A city has many attractions
1
2
3
4
5
6
7
class Attraction {
...
};

class City {
some_container<Attraction> attractions;
};

the attractions can be classified into various types
1
2
3
4
class Attraction {
    enum Type {Theater, Zoo, Sports};
    enum Type type;  // type of this attraction
};

a tourist will first choose a city from a list of cities displayed in alphabetical order

So we need a container of cities and it should be sorted alphabetically: std::set is good for this:
1
2
3
4
5
6
7
8
9
10
11
12
class City {
...
bool operator < (const City &rhs);   // less-than operator compares city names
};

set<City> cities;
City *getCity(some_container<City> &cities)
{
    // Display the names
    // get a user selection
    // return pointer to selection, or NULL if then chose none.
}


[A tourist will chose] the type of attraction from a list of attraction types
A static method in class Attraction can do this:
static enum Type getType();

and then [choose] the attraction itself

A static method within class City will do this:
1
2
3
4
5
static Attraction *chooseAtttraction(Attraction::Type type) {
    // display the attractions in this city that have this type.
    // Let user select one;
    return pointer to it, or NULL if they back out.
};


etc etc. Go through the assignment like this, sketching out the code with comments. Do this a few times until you're pretty sure that you have everything that you need. Now fill in the methods with actual code. The comments that you wrote can serve to comment what the code does.

why u use operator overloading?
In this case I would prob use a string for the attraction type, not an enum. This would allow the list of attraction types to be loaded from a config file in the future, allowing new types to be added without recompiling.

Andy
In this case I would prob use a string for the attraction type, not an enum

Andy makes a good point. I was thinking of an enum because you can compare types more quickly that way, but the flexibility of a string is compelling.

why u use operator overloading?

Because std::set<> uses operator< by default to compare items in the container.
I have a few ​favourite ​restaurants that I ​tend to go back to, but I'm always ​open to new suggestions (= ​willing to ​try new ​ones that ​people ​suggest).
My class has sport culture and shopping
Topic archived. No new replies allowed.