Checking rooms

Hey there guys! I was wondering if someone could help me make a function to check that I tick off a room in a text based adventure game to make sure that I don't go back in there and that it counts how many rooms I've been in
Do you have any code?
not exactly, I'm trying an exercise in class and I'm not sure how I would do it. Currently I'm thinking about setting up a bool for isNotVisited(); and Visited(); that I could use for graphs aswell
If you have control over the room struct, just add a boolean indicating whether or not you have been there.

If you can't modify the room struct, create yourself a std::set containing pointers to rooms you have visited.

Good luck!
Currently I'm thinking about setting up a bool for isNotVisited(); and Visited();


It's a question of style, but I would create only one of these (Visited()) and then use !Visited() if I wanted to know that it wasn't visited.

The reason to create Visited() instead of isNotVisited() is because, to me, it always makes sense to record the positive sense of a boolean attribute. Otherwise you start having to write code like if (!flagNotTripped()) which not nearly as clear as if flagTripped()
Topic archived. No new replies allowed.