Add code to the function named worldFindValue. The function should takes a World, two references to ints and a NodeValue as parameters. The ints represent a row and a column, and the NodeValue is the value to search for. First, the function should set the row and column parameters to both be -1. Then it should search the World for a node with a value equal to the NodeValue parameter and, if it finds one, set the row and column parameters to that node's location. If there is more than one such value, you can use the location of any of them. Note: At the end of this function, the row and column will have values of -1 if and only if the World does not contain search value. Warning: The TestWorld1B.cpp file cannot be used to test this function until worldLoadAll is working (a later step). Add code to the function named worldClear, which takes a World as a parameter. It should set every element of the array to INACCESSIBLE. Add code to the function named worldDebugPrint that takes a World as a parameter. It should print out all the node values in the world in a grid and separated by tabs. Hint: Display the values in the array using two nested for-loops with cout statements inside. Print a newline (endl) after the last value in each line and a tab (′\t') after each other value. Warning: You must match this format exactly, including using tabs (not spaces) to separate values on the same line. Otherwise, the test program will think the output is incorrect and dock you marks. Warning: The TestWorld1B.cpp file cannot be used to test this function until worldLoadAll is working (a later step). Add code to the function named worldLoadNodes that takes a World and a string as parameters. The string represents the file name to load the nodes from. You should first open this data file for reading. Then load (i.e., read) the first ROW_COUNT * COLUMN_COUNT integers from the file into the World array. If the file cannot be opened, print an error message. Hereafter, you should always print an error message when a file cannot be opened. Hint: Read in the world nodes using formatted I/O (>> notation). Optional: Close the input file when you are done. If you do not, it will automatically be closed when the ifstream variable goes out of scope, which is normally at the end of the function. Add code to the function named worldLoadAll that takes a World and a string as parameters. The string represents the game name. Use the game name parameter to calculate the names of the node data file and text data file (e.g. "blizzard" becomes "blizzard_grid.txt" and "blizzard_text.txt"). At this stage, use the first of these filename to call the worldLoadNodes function. In Part C, you will use the second of these filenames to call the worldLoadDescriptions function. Hint: You can use “+” to add two strings, i.e., "Fred " + "Flintstone" gives "Fred Flintstone". Hint: As debugging, print your filenames to make sure they are exactly right. Test your World module using the TestWorld1B.cpp program again. At this point, it should compile, run without crashing, and award you full marks.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Add code to the function named worldFindValue. The function should takes a World, two references to ints and a NodeValue as parameters. The ints represent a row and a column, and the NodeValue is the value to search for. First, the function should set the row and column parameters to both be -1. Then it should search the World for a node with a value equal to the NodeValue parameter and, if it finds one, set the row and column parameters to that node's location. If there is more than one such value, you can use the location of any of them. Note: At the end of this function, the row and column will have values of -1 if and only if the World does not contain search value. Warning: The TestWorld1B.cpp file cannot be used to test this function until worldLoadAll is working (a later step). Add code to the function named worldClear, which takes a World as a parameter. It should set every element of the array to INACCESSIBLE. Add code to the function named worldDebugPrint that takes a World as a parameter. It should print out all the node values in the world in a grid and separated by tabs. Hint: Display the values in the array using two nested for-loops with cout statements inside. Print a newline (endl) after the last value in each line and a tab (′\t') after each other value. Warning: You must match this format exactly, including using tabs (not spaces) to separate values on the same line. Otherwise, the test program will think the output is incorrect and dock you marks. Warning: The TestWorld1B.cpp file cannot be used to test this function until worldLoadAll is working (a later step). Add code to the function named worldLoadNodes that takes a World and a string as parameters. The string represents the file name to load the nodes from. You should first open this data file for reading. Then load (i.e., read) the first ROW_COUNT * COLUMN_COUNT integers from the file into the World array. If the file cannot be opened, print an error message. Hereafter, you should always print an error message when a file cannot be opened. Hint: Read in the world nodes using formatted I/O (>> notation). Optional: Close the input file when you are done. If you do not, it will automatically be closed when the ifstream variable goes out of scope, which is normally at the end of the function. Add code to the function named worldLoadAll that takes a World and a string as parameters. The string represents the game name. Use the game name parameter to calculate the names of the node data file and text data file (e.g. "blizzard" becomes "blizzard_grid.txt" and "blizzard_text.txt"). At this stage, use the first of these filename to call the worldLoadNodes function. In Part C, you will use the second of these filenames to call the worldLoadDescriptions function. Hint: You can use “+” to add two strings, i.e., "Fred " + "Flintstone" gives "Fred Flintstone". Hint: As debugging, print your filenames to make sure they are exactly right. Test your World module using the TestWorld1B.cpp program again. At this point, it should compile, run without crashing, and award you full marks.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education