Internal Code: MAS3343
Software Design and Implementation
Case Study:
Create a game prototype using modern C++. This should be a text based game. The game is laid out as a map. The map is composed of areas which have at least one entrance and exit. Each area is composed of rooms This game map should be represented by a stl container of area objects. The various objects that are part of the game map will have links between them represented by pointers between the objects. If any of your owning containers need pointers to objects (such as for polymorphism) you should use containers of safe pointer objects. However avoid additional memory allocation as much as possible as your program will run faster.
Questions:
1. Command Line arguments
When the program is started it must be invoked at least with how to load the data via either the -- ascii_load or -- binary_load arguments (not both, of course). These specify whether to load from an ascii or binary source. If loading from an ascii source, the path specified must be a directory - use boost::filesystem to check this. If loading from a binary file, the filename must point to a file which has been saved in binary format - I will specify that further in the requirement “loading of data(binary) below.
Your program must also handle two further optional arguments: -- ascii_save and -- binary_save. These are optional and if both are left out, your program should default to saving changes to the file that data was originally loaded from. However if one or more are specified (there’s no reason
that both cannot be specified) then just save to the names specified. Of course, the destination specified by -- ascii_save (if it already exists) must be a directory and for -- binary_save must be a file.
2. Loading and saving of data robustly (ascii)
Your program should load the provided data into classes specified to achieve the required functionality. Your loading and saving of ascii data must be robust. It must not corrupt the files that are saved and all reads and writes must be validated.
3. Loading and Saving of data (binary)
Please ensure you understand the difference between saving / loading as binary and ascii. Binary formats mean that you save to disk the bit patterns of what is held in memory. If there are any pointers in the structures you are saving, these will need to be serialised first. It is advisable to have a serializable version of each of your classes orhave that constructed by your saver/loader classes.
For example, the format for the binary file will be as follows - please note that everything here is written in binary, not ascii:
? The number of areas in the world as an integer
? For each area: write the id, name, description, the number of entrances followed the start room id, end room id and direction. The number of exits followed by the start room id, end room id and direction (remember that these are the global, not local room ids).
? Next you will write the number of rooms that the area contains followed by serialisation of the room data in a similar way as I described above the
serialisation of area data.
? Next, you will write the number of items in the game (the number of items in the item list, not the copies) followed by a serialisation of the item data in the same way as above.
? Finally you will write the number of players followed by a serialisation of the player data.
? Please note that what this means is that the data classes must be the same as those provided in the class diagram I have provided or this will not work - each of the fields needs to be presented in the same order as represented on the class diagram. I will provide you with a sample binary file to load so you can test that your algorithm is correct. I expect this part to be one of the more difficult components of the assignment. The plan at this point is to provide you with sample binary files by the beginning of week 9.
Correct use of inheritance
Use inheritance whereever you can but in particular I require you to design an inheritance heirarchy for items (it doesn’t make sense in terms of object oriented design to have a single item class). The same is true for input/output classes.
Correct use of operator overloading
All your data classes should have operator<< and operator>> overloaded to simplify the reading and writing of data in ascii format.
Correct use of exception handling
All error handling and validation should be done by the use of the exception handling mechanisms rather than returning bool or enum state values. All exceptions which are thrown must be caught. It is optional whether you implement your own exception classes or use c++’s built in exception classes.
Correct implementation of Model-View-Controller design pattern
The class design you have been provided with has a partially implemented mvc pattern. Complete this pattern and only use the mvc mechanisms to communicate between components to reduce coupling.
Handling of logins
Either fred or wilma should be able to login to your system. The user that starts the program needs to be presented with a login screen that looks like the following:
Welcome to Explore World
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Please enter your username: fred
Please enter your password: dinner
Error: invalid password entered. Please try again.
Please enter your username: fred
Please enter your password: dino
Welcome to Explore World. We hope you enjoy your stay!
Please note that your program should convert the password entered into a hash (an integer) using std::hash before sending it from the view to the other mvc components. You are provided with two players in the startup data. wilma whose password is pebbles and fred whose password is dino.