Visual Studio- Information Technology and Computer Science Assignment Help

Download Solution Order New Solution
Assignment Task: 
Visual Studio- Information Technology and Computer Science Assignment Help

In this assignment, you will add caverns to the cave.  A cavern is a rectangular open area.  For simplicity, assume that no two caverns will ever touch.  When the game prints a description for the cavern, it will print the cavern size and the directions there are tunnels leaving the cavern. 


Part A: The Direction Type 


In Part A, you will create a type and some constants to represent directions.  Put these in a file named Direction.h. Perform the following steps: 
1. Use a typedef to define Direction as an alias to unsigned int. 
2. Define NORTH, SOUTH, EAST, and WEST as Direction constants with the respective values 0, 1, 2, and 3. 
3. Define DIRECTION_COUNT as an unsigned int constant with a value of 4. 

 

Part B: The Position Type 


In Part B, you will create a type to represent a position and two associated functions.  Put the type definition and the function prototypes in a file named Position.h and the function implementations in a file named Position.cpp.
You will add functions with the following prototypes:
• Position to position (int south, int east); 
• bool is in map (const Position& position);// first variant 
• bool is in map (const Position& pos_min, // second variant int south_size, int east_size); 
• Position move direction (const Position& position,Direction direction); 

Perform the following steps: 
1. Define Position as a record (struct) that contains two member fields.  These are both ints and represent the south and east coordinates of the position. 
2. Copy in the function prototypes shown above.  They should be after the Position record.  Also include the Direction.h file at the top of the Position.h file. 
• Recommended: To get started on implementing the functions, copy the function prototypes into the Position.cpp file and then change the semi-colons to opening/closing braces { }. 
3. Add an implementation for the toPosition function.  The function should declare a Position variable, assign the value of the south parameter to the south field of the variable, repeat for east, and return the Position variable. 
4. Copy in and adapt the mapIsInMap function from the Map.cpp file to become the first variant of the isInMap function.  Your new function will not need the parameters from the original function. One adaptation is that where the original function said just “south”, you will use the south field of the position variable. 
• Perhaps surprisingly, C++ allows you to have two functions with the same name if they have different numbers of parameters or different types of parameters. We say that the function name is overloaded. 
5. Add an implementation of the second variant of the isInMap function that returns true if an entire rectangle is inside the Map and false otherwise.  The rectangle is specified by the parameters that say its minimum position and sizes in each of two dimensions. 
6. Add an implementation for the moveDirection function.  This function should calculate a new Position that is one away from the given position in the specified direction.  The new Position will be different from the original position because it will have either the south or the east field changed by either increasing it by one or decreasing it by one. 

 

Part C: The Cavern Type


In Part C, you add a type to represent a cavern and some functions to manipulate it.  Put the code in files named Cavern.h and Cavern.cpp.  You will also write comments called interface specifications for the functions associated with the Cavern type in the Cavern.h interface file, in the format described in class
By the end of Part C, the cavern type will have associated functions with the following prototypes: 
• void cavernInit (Cavern& cavern,int south_size1, int east_size1); 
• int cavernGetSouthSize (const Cavern& cavern); • int cavernGetEastSize (const Cavern& cavern); 
• bool cavernIsExit (const Cavern& cavern, Direction direction); 
  Position cavernGetExitPosition (const Cavern& cavern, Direction direction); 
• void cavernAddExit (Cavern& cavern, Direction direction, const Position& position); 
• void cavernPrint (const Cavern& cavern); 

Perform the following steps: 
1. Add a constant named CAVERN_SIZE_MIN to represent the minimum size of a cavern.  It should have a value of 2. 
2. Define Cavern as a record.  It should have member fields to represent its size in both northsouth and east-west dimensions.  It should also have two member arrays, each of a size based on the number of directions, as recorded in Direction.h. One array should represent whether or not there is an exit in each of the directions. The other array should store the corresponding position of the exit for each direction.  Add any needed #includes. 
• A Cavern does not have a field for its position because this information is not needed for this software project. Instead, we will store the positions of its exits in later steps. 
3. Copy in the function prototypes into Cavern.h. Copy in the template for an interface specification from the website once before every function prototype (choose either).

  • http://www2.cs.uregina.ca/~anima/115/Terms/201930/Assignments/Assignment2/Interfac specification-template.txt
  • http://www2.cs.uregina.ca/~anima/115/Terms/201930/Assignments/Assignment2/Interfac specification-short-template.txt

4. Add implementation for the cavern in it function.  Set the size of the cavern to the values of the appropriate parameters.  Set the cavern to have no exits. 
• Documentation: Add preconditions that the south and east sides are at least CAVERN_SIZE_MIN. 
5. Add implementations for the cavernGetSouthSize and cavernGetEastSize functions.  These functions should return the respective dimensions of the cavern. 
6. Add implementation for the cavern exit function.  This function should return whether there is an exit in the specified direction. 
• Documentation: Add a precondition that the direction is less than DIRECTION_COUNT. 
7. Add an implementation for the cavernGetExitPosition function.  This function should return the position of the exit in the specified direction. 
• Documentation: Add preconditions that the direction is less than DIRECTION_COUNT and that there is an exit in that direction.
8. Add an implementation for the cavernAddExit function.  This function should change the cavern to have an exit in the specified direction that is at the specified position. 
• Documentation: Add preconditions that the direction is less than DIRECTION_COUNT and that there is not already an exit in that direction.
9. Add an implementation for the cavernPrint function.  The function should first print "You are in a cavern SSS0 ft by EEE0 ft in size.", where SSS is the north-south size of the cavern and EEE is the east-west size.  Putting a zero (0) after a number makes it appear ten times bigger than it is. Then the function should check whether there is an exit to the north and, if so, print "There is a tunnel leading north.".  Also check for tunnels to the south, east, and west.  Each message should be printed on its own line. 
• Note: A possible cavern description would be: 

  1. You are in a cavern 30 ft by 50 ft in size. 
  2. There is a tunnel leading south. 
  3. There is a tunnel leading west. 

• Debugging: Declare a few variables of the Cavern type in main and initialize them, add exits to them, and then print them out. 
10. Test your Cavern type with the Main2C.cpp file on the course website. 

 

Part D: Update the Map to Allow Caverns


In Part D, you will change the processed map to be able to store caverns.  The caverns will be represented by a special value based on the index of the cavern.  This will allow the cavern index to be determined from a position in the processed map.  No new files will be added. 
By the end of Part D, the Shape type will have functions with the following prototypes (new ones are in boldface):
• bool shapeIsTunnel (Shape shape); 
• bool shapeIsCavern (Shape shape); 
• unsigned int shapeGetCavernIndex (Shape shape); 
• Shape shapeGetCavernShape (unsigned int cavern_index); 
• char shapeGetMapChar (Shape shape); 
• Shape shapeCalculate (bool is_open_north, bool is_open_east, bool is_open_south, bool is_open_west); 
The map will have associated functions with the following prototypes: 
• void mapInit (Shape map[][MAP_SIZE_EAST]); 
• void mapPrintMap (const Shape map[][MAP_SIZE_EAST]); 
• bool mapIsInMap  (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• bool mapIsSolid  (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• bool mapIsTunnel (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• bool mapIsCavern (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• unsigned int mapGetCavernIndex (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• void mapPrintDescription (const Shape map[][MAP_SIZE_EAST], int south, int east); 
• void mapSetAt (Shape map[][MAP_SIZE_EAST], int south, int east, Shape shape); 
• void mapSetRectangle (Shape map[][MAP_SIZE_EAST], int south_min, int east_min,int south_size, int east_size, Shape shape);

Perform the following steps: 
1. Copy in the new (bolded) function prototypes to the appropriate files. 
2. Add another constant to Shape.h named SHAPE_FIRST_CAVERN with a value of 17.  This value (and all larger values) will be used to represent a cavern in the processed map. 
Note: If you have a constant for the array size for a character array in the shapeGetMapChar function, you should not increase this constant.  (In the posted solution, this variable is named SHAPE_COUNT.) 
3. Add an implementation for the shapeIsCavern function.  It should return true if the shape parameter is greater than or equal to SHAPE_FIRST_CAVERN and false otherwise. 
4. Add an implementation for the shapeGetCavernIndex function.  It should return the value of the shape parameter minus SHAPE_FIRST_CAVERN. 
 Remember: Shapes are really unsigned ints, so we can use math operators on them. 
5. Add implementation for the shapeGetCavernShape function.  It is the opposite of the previous function and should return the value of the cavern_index parameter plus SHAPE_FIRST_CAVERN. 
6. Update the shapeGetMapChar function.  If shape is a cavern, calculate whether the shape is an even number (shape % 2 == 0).  If so return ':' and if not return '.'.  If shape is not a cavern, return the same value as in Assignment 1. 
• Note: We are using two different chars to display caverns to aid in the marking process. 
7. Test your improved Shape type with the Main2D.cpp file on the course website. 
8. Add implementations for the mapIsCavern and mapGetCavernIndex functions.  These functions should call the shapeIsCavern and shapeGetCavernIndex functions. 
• Note: You should not need to update mapPrintMap. 

 

Part E: Add Caverns to the Map 


In Part E, you detect caverns while processing the map and store them in an array.  You will also store special shape values in the map.  No new files will be added. 
By the end of Part E, the raw map will have associated functions with the following prototypes: 

• void rawMapLoad (char raw[][MAP_SIZE_EAST], const std::string& filename); 
• void rawMapPrint (const char raw[][MAP_SIZE_EAST]); 
• bool rawMapIsOpen (const char raw[][MAP_SIZE_EAST], int south, int east); 
• Shape rawMapCalcuateShape (const char raw[][MAP_SIZE_EAST], int south, int east); 
• bool rawMapIsCavern (const char raw[][MAP_SIZE_EAST], int south, int east); 
• int rawMapGetCavernSouthSize (const char raw[][MAP_SIZE_EAST], int south, int east); 
• int rawMapGetCavernEastSize (const char raw[][MAP_SIZE_EAST], int south, int east); 
• int rawMapFindExitToSouth (const char raw[][MAP_SIZE_EAST], int south, int east, int max_distance); 
• int rawMapFindExitToEast (const char raw[][MAP_SIZE_EAST], int south, int east, int max_distance); 
• Cavern rawMapCalculateCavern (const char raw[][MAP_SIZE_EAST], int south, int east); 

Perform the following steps: 
1. Change main to load the map2.txt map.  It has caverns on it. 
2. Copy in the new (bolded) function prototypes to the appropriate files. 
3. Add implementation for the rawMapIsCavern function.  This function should return whether the specified position is in a cavern that extends south, east, and southeast from here.  To determine this, check the following positions: the current position, the position to the east, the position to the south, and the position to the southeast.  If the raw map is open at all of these positions, this is a cavern and the function should return true.  Otherwise, the function should return false. 
• Note: Later in the assignment, we will use this function to find the northwest corner of caverns. This is the location in the cavern that has the minimum coordinate values. 
• Debugging: Add a check in the main function to call the rawMapIsCavern function for several positions and print out the results of each.  Note, at this stage of the assignment, if a cavern is larger than 2 x 2, then the cavern will be detected at every position except the south and east edges. 
4. Add a check to the main function when processing the map (just before using the rawMapCalculateShape function).  If a position in the raw map is open, check if it is a cavern using the rawMapIsCavern function and, if so, set the processed map to SHAPE_FIRST_CAVERN. If it is not a cavern, calculate the tunnel shape as in Assignment 1
• Debugging: At this point, every cavern should appear on the map as a block of '.' characters.  However, there will be tunnel characters on the east and south sides of the caverns instead of ‘.’ characters. This problem will be fixed in a later step. 
5. Add implementation for the rawMapGetCavernSouthSize function that determines the size of the cavern from north to south.  This function should check if both the specified position and the position to the east of it are open.  If both of them are open, that horizontal row is part of the cavern and the function should repeat the check for the next row to the south.  When the function finds a non-open position, it has reached the end of the cavern and should return the number of entirely-open rows it has passed. 
6. Add implementation for the rawMapGetCavernEastSize function that is analogous to the previous function. (Since we have assumed that caverns are always rectangular and never touch, it is sufficient to find the east side in the top two rows of the rectangle.) 
7. Add implementation for the rawMapCalculateCavern function.  This function should declare a Cavern instance, determine its size in two dimensions using functions in the RawMap module, initialize the cavern instance, and return it.  For now, don't add any exits. 
8. Add a constant to the main function representing a maximum number of caverns with a value of 25.  Then add an array of that many caverns and a variable to count how many have been used.  First, add a check to the map processing to skip positions where the processed map is already part of a cavern.  If it is not, check for a cavern in the raw map at the current position.  If there is not a cavern, calculate the tunnel Shape value as you did in Assignment 1.  If you do find a cavern, initialize it using the rawMapCalculateCavern function and store it in the cavern array.  Then calculate the Shape value for that cavern using shapeGetCavernShape, set the rectangle of the processed map corresponding to the cavern to that Shape value, and increment the cavern count.  The result should be that each cavern gets a unique value in the processed map. 
Pseudocode for this task is given below: set cavern count to zero repeat for i = all rows in the map  repeat for j = all columns in the map   if there is not a cavern at position (i, j) in the processed map    if there is not a cavern at position (i, j) in the raw map     calculate the shape at position (i, j) as in assignment 1, using the raw map set position (i, j) in the processed map to the calculated shape otherwise declare and calculate a cavern at position (i, j) in the raw map  store this cavern in the cavern array in the position given by the current cavern count determine the cavern shape (a number) based on the cavern count  determine the south-size of the cavern 
9. Add a check to the main function when printing the description for a position in the map.  If there is a cavern at that position, print the description for that cavern.  Otherwise, print the tunnel description as in Assignment 1. 
10. Add implementation for the rawMapFindExitToSouth function that determines the location of a cavern exit, if any, in an east-to-west line of array elements just past the edge of the cavern.  The function should start by checking if the specified position is open.   If so, this position is the exit and the function should return how many positions in an eastward direction it has moved.  Otherwise, the function should repeat the check for the next position to the east.  If the function has checked max_distance positions and none of them were open, it should return -1. 
11. Implement the rawMapFindExitToEast function. 
12. Update the rawMapCalculateCavern function to check for exits on all four sides of the cavern. 

 

Formatting
1. Neatly indent and format your program. Use a consistent indentation scheme and make sure to put spaces around your arithmetic operators, e.g., x = x + 3;. 

 

This IT and CS Assignment have been solved by our IT and CS Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
 

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.