Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

someone answered the A1, B1, i need the other remaining parts from 3 to 5 3 of 5 sem, store each in a point variable

image text in transcribed
image text in transcribed
image text in transcribed
someone answered the A1, B1, i need the other remaining parts from 3 to 5
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
3 of 5 sem, store each in a point variable and print them all. Again, this main() is also for unit testing. B. establish the robot's world 1. Create a class called world that has one data member and two function members: the data member is an array of three point objects, each one storing the location of one of the 3 coins the robot is looking for void print() const This function prints out the locations of the three coins. void set int i, int x, int y This function sets the location of the l-th coin in the data member array to (x,y). 2. Modify your main() that you created in part A to instantiate a world object and store the validated and converted command-line arguments in the point array within the world object Then call the world object's print() function to echo the input. Again, this main() is for unit testing C. define the robot 1. Create a robot class that has the following data and function members: a point object to store the robot's current location in the world an enumerated data type. called orientation_type, that defines the four directions that the robot could be facing (north, south, east or west), i.e., its orientation a variable to store the robot's current orientation void init(): This function initializes the robof's current location to (0.0) and its current orientation to east. void print() const: This function prints the robot's current location and orientation in a pretty format, such as: I am at (0.0) and I am facing east. void setOrientation orientation_type orientation : This function sets the value of the robot's orientation data member bool forward(); This function simulates the robot moving forward one step in the direction that it is facing. It checks to make sure that the robot is not at the edge of its world. It retums true if the robot moves forward successfully and false if the robot is at the edge of its world and cannot move forward. vold turnCWU). This function changes the robot's orientation, simulating a tum in the clockwise direction. void turnAntiCwO): This function changes the robot's orientation, simulating a turn in the anti-clockwise direction. bool eastEnd): This function returns true if the robot has reached the east edge of its world. bool westEndl): This function returns true if the robot has reached the west edge of its world. bool northEnd): This function returns true if the robot has reached the north edge of its world. .bool southEnde This function returns true if the robot has reached the south edge of its world bool zag(; This function is called when the robot has been moving east and has reached the east edge of its world, in which case it should turn clockwise, go forward one step south and turn clockwise again (where it will be heading west for its next move) bool zigo: This function is called when the robot has been moving west and has reached the west edge of its world, in which case it should turn anti-clockwise, go forward one step south and turn anti-clockwise again (where it will be heading east for its next move). 2. Now modify the main() from the previous step to instantiate a world object. Define and perform some unit tests on each of the function members in the world class. For example, first call init() and then call printl) to make sure the robot's position and orientation are correctly initialized. Or, call init(): forward(): print(); to verify that forward() works as you expect. Do the same with tumCwO). turnAntiCW)zig() and zago. Again, this main() is for your testing, not for submission 3. Now modify the main() so that the robot traverses its world, starting at (0,0) and ending at (9. 9), by visiting every cell in (0.9. 10. 91) space (ie., all 100 cells). Unit test this by printing out every cell visited, to make sure that the robot gets to all of them. D. find the coins Finally, you need to put in a check while the robot is traversing the world to see if it finds the coins. You make the design decision about how to do that. Every time the robot finds a coin, it should print out a message like: I am at (2,0) and I found the first coin! I'm gonna be rich! Yippeel Keep a count of how many moves the robot makes, and when the program exits, print a message saying how many moves the robot made. Note: of course, traversing every cell in turn is not an optimal search strategy by any means, but we will refine it later in the semester. The exercise here is to develop classes of your own with data and function members. Extra: Make a Roomba robot game. E.marking rubric This assignment is worth 12 points. The breakdown is as follows: point class with two data members (x and y) and four function members (print().set().getX() and getY()) (0.5 point) world class with one data member(coins) and two function members (print) and sett) (0.5 point) robot class with two data members, enumerated type definition, and 12 function members (init(). print().setOrientation(). forward(), turncwo). turnAnticwo). eastEndC), westEnd(), northEndo). southEndo), zag) and zig()) (3 points) handling of command-line input or just inputs, including error handling (point) complete traversal of the world by the robot (visiting every cell until all coins are found) (1 point) determining if coins are found, reporting when they are found and keeping track of how many have been found, including stopping when the 3rd coin is found (2 points) counting and reporting the number of moves made by the robot (1 point) Input Validation ( point) Documentation (1 point) 5 CSC211 assignment 2 Instructions Submission Instructions It is worth 12 points. It is due on Tuesday, March 2nd and must be submitted as follows: . Follow instructions: Print Submission: Print your code along with working screenshots and output. Google Folder 1. Create a google folder for CSC211 and share with my gmail with the subject line CSC211 hw2. 2. Attach ONLY the h.cpp source code files created and below and along with screenshots of output and working code. Failure to follow these instructions will result in points being taken away from your grade. The number of points will be in proportion to the extent to which you did not follow instructions... (which can make it a lot harder for me to grade your work - grrrr!) Program description For this assignment, you will develop a program that simulates a robot moving around in a 2-dimensional world, looking for coins. The robot's current location is represented by an (x) point in space. Imagine that the robot has a controller that receives commands one at a time. Each command will tell it to move forward or turn 90 degrees, either clockwise or anti-clockwise. The program will have a broad control loop, and for each iteration of the loop, the robot must decide what to do fe, which command to execute). The goal is for the robot to locate all the coins hidden in its world. The robot's world is 10 * 10 units in size, and the x and y coordinates are in the range 10. 91 (le, from 0 to 9, inclusive) You will create 3 classes, each with multiple data and function members, and a maino. Each class is described in detail below, with step-by-step instructions for developing the various components of each class and testing the components individually. In the end, you'll write the main() and put all the pieces together-and this final product is what you'll submit. The intermediary test programs are for your benefit as a developer and should not be submitted. Incidentally, these are called unit tests and are created to let you test and debug the individual units of a 1 2 of 5 complex program. By the end of the semester, you should have gained the skills and experience to devise and construct your own unit tests, without me giving you step-by-step instructions. A. read and store command-line input The program will be named Took-for". It will receive input from the command line indicating the locations of the coins to look for, in the following form prompts look for In other words, the program will take 6 input values, which are pairs of (x, ) coordinates for three coins hidden in the robot's world 1. Create a point dass. The class should have two in data members: x and y. The class should have four function members: - void print) const; This function prints out the values of the data members x and y. . void set int x, inty) This function sets the values of the data members x and y. Note that since the function arguments are also called x and y, you should use the this pointer to disambiguate between the class's data members and the function arguments. int getX() This function returns the value of the data member. - int getyo This function returns the value of the y data member 2 Create a maint) for testing that reads two command-line arguments x and y, validates, stores and prints them. . Check that the user has entered 2 command-line arguments (remember that arge contains the number of command-line arguments, including the name of the C++ program you are running). If not, print an error message and exit the program. Convert the command-line arguments to integers. Hint use the atoll function. If you are not familiar with this function, see here Check that the arguments are within the range 10. 9. If not, print an error message and exit the program Instantiate a point object fi.e., declare a variable of type point) and store the values of the command-line arguments in that object. Echo the arguments (ie., display them back to the user). 3. Modify your main() that you created above to read in 6 arguments from the command-line instead of two 2 2 3 of 5 Validate them. sore each in a point variable and print them all. Again, this main() is also for ur testing unit B. establish the robot's world 1. Create a class called world that has one data member and two function members the data member is an array of three point objects, each one storing the location of one of the 3 coins the robot is looking for void print const This function prints out the locations of the three coins. void setinti, int x, int y This function sets the location of the th coin in the data membet armay to 2. Modify your main that you created in part A to instantiate a world object and store the validated and converted command-line arguments in the point array within the world object Then call the world objects print() function to echo the input. Again, this main for unit testing C. define the robot 1. Create a robot class that has the following data and function members - a point object to store the robot's cument location in the world an enumerated data type, called crientation_type that defines the four directions that the robot could be facing (north, south east or west). Le.. its orientation a variable to store the robot's current orientation void init(); This function initializes the robot's current location to (0) and is current orientation to cast void print) const: This function prints the robot's current location and orientation in a pretty format such as: I am af (0.0) and I am facing east void setOrientation orientation_type orientation : This function sets the value of the robor's orientation data member bool forward This function simulates the robot moving forward one step in the direction that it is facing. It checks to make sure that the robot is not at the edge of its world retums true the robot moves forward successfully and false if the robot is at the edge of world and cannot move forward. s forward successfully and also the robot is at the edge of its world and cannot move rd 4 of 5 vold tunc This function changes the robot's orientation simulating a tum in the clockwise direction void tumAnsCWO This function changes the trobet's creiertation simdating a tum in the enclockwise bool castEnd: This function returns tue it the robot has reached the cast edge of its world bool westend This function returns tue if the robot has reached the west edge of its world bool north End: This function returns true if the robot has reached the north edge of is world bool south End This function retums true if the robot has reached the south edge of its world bool agek This function is called when the robot has been moving east and has reached the cast edge of its world, in which case should tum clockwise, go forward one step south and tum dockwise again (where it will be heating west for its next move) bool 29: This function is called when the robot has been moving west and has reached the west edge of its world, in which case it should tum anti-clockwise, go forward one step south and tumn anti-clockwise again (where it will be heading east for next move 2. Now modify the main from the previous step to instantiate a world object Define and perform some unit tests on each of the function members in the world class. For example, first call it and then call print to make sure the robots position and orientation are correctly initialized. Or callint: forwardik print: to verify that forward) works as you expect. Do the same with tumCW), tumAnticw sig and zag Again, this main is for your testing, not for submission 3. Now modify the main) so that the tobot traverses its world, starting at (0) and ending at 9. by visiting every cell in 0.9. 10. 99 space e al 100 cells). Unit test this by printing out every coll visited to make sure that the robot gets to all of them D. find the coins Finally, you need to put in a check while the robot is traversing the world to see it finds the coins. You make the design decision about how to do that. Every time the robot find a con, it should print out a message the I am at (2.0) and I found the first con im gonna be rich Yippee! correctly inzed or call forward to verify that forward works as you expect Do the same with two, tumew),290) and zag. Again, this mains for Posting, not for submission 5 of 5 nocity the maint) so that the robot traverses its wort, staring at (0.0y and ending Visiting every cell 0.9 10. space fie al 100 cells). Unit test this by printing out cell visited to make sure that the robot gets to all of them D. find the coins Finally, you need to put in a check while the robot is braversing the world to see if finds the com. You make the design decision about how to do that. Every time the robot finds a con, it should point out a message the amat 2.0) and I found the first con 'm gonna be richt opeet Keep a count of how many moves the robot makes, and when the program exts, print a message saying how many moves the robot made Note: of course, traversing every call in tum is not an optimal search trategy by any means, but we will refine it later in the semester. The exercise here is to develop classes of your own with data and function members Extra: Make a Roomba robot E.marking rubric This assignment is worm 12 points. The breakdown is as follows: point class with two data members and ys and tour function members (print), set) gecXD and gy) (0.5 point world class with one data member coin) and two function members and se (0.5 poing robot class with two data members, enumerated type definition, and 12 function members in). print.setOneration), forward), tumCWD. tum dcWD. and westEnd, nortEnd) Southend,zago and 2) 13 points) - handing of commandine input or just inputs, including error handling (1 point complete traversal of the world by the robot (visiting every col unit all coins are found) (tpoint determining coins we found reporting when they are found and keeping track of how many have been found, including stopping when the 3rd coin is found points) counting and reporting the number of moves made by the robot ( peine Input Validation it point Documentation point 3 of 5 sem, store each in a point variable and print them all. Again, this main() is also for unit testing. B. establish the robot's world 1. Create a class called world that has one data member and two function members: the data member is an array of three point objects, each one storing the location of one of the 3 coins the robot is looking for void print() const This function prints out the locations of the three coins. void set int i, int x, int y This function sets the location of the l-th coin in the data member array to (x,y). 2. Modify your main() that you created in part A to instantiate a world object and store the validated and converted command-line arguments in the point array within the world object Then call the world object's print() function to echo the input. Again, this main() is for unit testing C. define the robot 1. Create a robot class that has the following data and function members: a point object to store the robot's current location in the world an enumerated data type. called orientation_type, that defines the four directions that the robot could be facing (north, south, east or west), i.e., its orientation a variable to store the robot's current orientation void init(): This function initializes the robof's current location to (0.0) and its current orientation to east. void print() const: This function prints the robot's current location and orientation in a pretty format, such as: I am at (0.0) and I am facing east. void setOrientation orientation_type orientation : This function sets the value of the robot's orientation data member bool forward(); This function simulates the robot moving forward one step in the direction that it is facing. It checks to make sure that the robot is not at the edge of its world. It retums true if the robot moves forward successfully and false if the robot is at the edge of its world and cannot move forward. vold turnCWU). This function changes the robot's orientation, simulating a tum in the clockwise direction. void turnAntiCwO): This function changes the robot's orientation, simulating a turn in the anti-clockwise direction. bool eastEnd): This function returns true if the robot has reached the east edge of its world. bool westEndl): This function returns true if the robot has reached the west edge of its world. bool northEnd): This function returns true if the robot has reached the north edge of its world. .bool southEnde This function returns true if the robot has reached the south edge of its world bool zag(; This function is called when the robot has been moving east and has reached the east edge of its world, in which case it should turn clockwise, go forward one step south and turn clockwise again (where it will be heading west for its next move) bool zigo: This function is called when the robot has been moving west and has reached the west edge of its world, in which case it should turn anti-clockwise, go forward one step south and turn anti-clockwise again (where it will be heading east for its next move). 2. Now modify the main() from the previous step to instantiate a world object. Define and perform some unit tests on each of the function members in the world class. For example, first call init() and then call printl) to make sure the robot's position and orientation are correctly initialized. Or, call init(): forward(): print(); to verify that forward() works as you expect. Do the same with tumCwO). turnAntiCW)zig() and zago. Again, this main() is for your testing, not for submission 3. Now modify the main() so that the robot traverses its world, starting at (0,0) and ending at (9. 9), by visiting every cell in (0.9. 10. 91) space (ie., all 100 cells). Unit test this by printing out every cell visited, to make sure that the robot gets to all of them. D. find the coins Finally, you need to put in a check while the robot is traversing the world to see if it finds the coins. You make the design decision about how to do that. Every time the robot finds a coin, it should print out a message like: I am at (2,0) and I found the first coin! I'm gonna be rich! Yippeel Keep a count of how many moves the robot makes, and when the program exits, print a message saying how many moves the robot made. Note: of course, traversing every cell in turn is not an optimal search strategy by any means, but we will refine it later in the semester. The exercise here is to develop classes of your own with data and function members. Extra: Make a Roomba robot game. E.marking rubric This assignment is worth 12 points. The breakdown is as follows: point class with two data members (x and y) and four function members (print().set().getX() and getY()) (0.5 point) world class with one data member(coins) and two function members (print) and sett) (0.5 point) robot class with two data members, enumerated type definition, and 12 function members (init(). print().setOrientation(). forward(), turncwo). turnAnticwo). eastEndC), westEnd(), northEndo). southEndo), zag) and zig()) (3 points) handling of command-line input or just inputs, including error handling (point) complete traversal of the world by the robot (visiting every cell until all coins are found) (1 point) determining if coins are found, reporting when they are found and keeping track of how many have been found, including stopping when the 3rd coin is found (2 points) counting and reporting the number of moves made by the robot (1 point) Input Validation ( point) Documentation (1 point) 5 CSC211 assignment 2 Instructions Submission Instructions It is worth 12 points. It is due on Tuesday, March 2nd and must be submitted as follows: . Follow instructions: Print Submission: Print your code along with working screenshots and output. Google Folder 1. Create a google folder for CSC211 and share with my gmail with the subject line CSC211 hw2. 2. Attach ONLY the h.cpp source code files created and below and along with screenshots of output and working code. Failure to follow these instructions will result in points being taken away from your grade. The number of points will be in proportion to the extent to which you did not follow instructions... (which can make it a lot harder for me to grade your work - grrrr!) Program description For this assignment, you will develop a program that simulates a robot moving around in a 2-dimensional world, looking for coins. The robot's current location is represented by an (x) point in space. Imagine that the robot has a controller that receives commands one at a time. Each command will tell it to move forward or turn 90 degrees, either clockwise or anti-clockwise. The program will have a broad control loop, and for each iteration of the loop, the robot must decide what to do fe, which command to execute). The goal is for the robot to locate all the coins hidden in its world. The robot's world is 10 * 10 units in size, and the x and y coordinates are in the range 10. 91 (le, from 0 to 9, inclusive) You will create 3 classes, each with multiple data and function members, and a maino. Each class is described in detail below, with step-by-step instructions for developing the various components of each class and testing the components individually. In the end, you'll write the main() and put all the pieces together-and this final product is what you'll submit. The intermediary test programs are for your benefit as a developer and should not be submitted. Incidentally, these are called unit tests and are created to let you test and debug the individual units of a 1 2 of 5 complex program. By the end of the semester, you should have gained the skills and experience to devise and construct your own unit tests, without me giving you step-by-step instructions. A. read and store command-line input The program will be named Took-for". It will receive input from the command line indicating the locations of the coins to look for, in the following form prompts look for In other words, the program will take 6 input values, which are pairs of (x, ) coordinates for three coins hidden in the robot's world 1. Create a point dass. The class should have two in data members: x and y. The class should have four function members: - void print) const; This function prints out the values of the data members x and y. . void set int x, inty) This function sets the values of the data members x and y. Note that since the function arguments are also called x and y, you should use the this pointer to disambiguate between the class's data members and the function arguments. int getX() This function returns the value of the data member. - int getyo This function returns the value of the y data member 2 Create a maint) for testing that reads two command-line arguments x and y, validates, stores and prints them. . Check that the user has entered 2 command-line arguments (remember that arge contains the number of command-line arguments, including the name of the C++ program you are running). If not, print an error message and exit the program. Convert the command-line arguments to integers. Hint use the atoll function. If you are not familiar with this function, see here Check that the arguments are within the range 10. 9. If not, print an error message and exit the program Instantiate a point object fi.e., declare a variable of type point) and store the values of the command-line arguments in that object. Echo the arguments (ie., display them back to the user). 3. Modify your main() that you created above to read in 6 arguments from the command-line instead of two 2 2 3 of 5 Validate them. sore each in a point variable and print them all. Again, this main() is also for ur testing unit B. establish the robot's world 1. Create a class called world that has one data member and two function members the data member is an array of three point objects, each one storing the location of one of the 3 coins the robot is looking for void print const This function prints out the locations of the three coins. void setinti, int x, int y This function sets the location of the th coin in the data membet armay to 2. Modify your main that you created in part A to instantiate a world object and store the validated and converted command-line arguments in the point array within the world object Then call the world objects print() function to echo the input. Again, this main for unit testing C. define the robot 1. Create a robot class that has the following data and function members - a point object to store the robot's cument location in the world an enumerated data type, called crientation_type that defines the four directions that the robot could be facing (north, south east or west). Le.. its orientation a variable to store the robot's current orientation void init(); This function initializes the robot's current location to (0) and is current orientation to cast void print) const: This function prints the robot's current location and orientation in a pretty format such as: I am af (0.0) and I am facing east void setOrientation orientation_type orientation : This function sets the value of the robor's orientation data member bool forward This function simulates the robot moving forward one step in the direction that it is facing. It checks to make sure that the robot is not at the edge of its world retums true the robot moves forward successfully and false if the robot is at the edge of world and cannot move forward. s forward successfully and also the robot is at the edge of its world and cannot move rd 4 of 5 vold tunc This function changes the robot's orientation simulating a tum in the clockwise direction void tumAnsCWO This function changes the trobet's creiertation simdating a tum in the enclockwise bool castEnd: This function returns tue it the robot has reached the cast edge of its world bool westend This function returns tue if the robot has reached the west edge of its world bool north End: This function returns true if the robot has reached the north edge of is world bool south End This function retums true if the robot has reached the south edge of its world bool agek This function is called when the robot has been moving east and has reached the cast edge of its world, in which case should tum clockwise, go forward one step south and tum dockwise again (where it will be heating west for its next move) bool 29: This function is called when the robot has been moving west and has reached the west edge of its world, in which case it should tum anti-clockwise, go forward one step south and tumn anti-clockwise again (where it will be heading east for next move 2. Now modify the main from the previous step to instantiate a world object Define and perform some unit tests on each of the function members in the world class. For example, first call it and then call print to make sure the robots position and orientation are correctly initialized. Or callint: forwardik print: to verify that forward) works as you expect. Do the same with tumCW), tumAnticw sig and zag Again, this main is for your testing, not for submission 3. Now modify the main) so that the tobot traverses its world, starting at (0) and ending at 9. by visiting every cell in 0.9. 10. 99 space e al 100 cells). Unit test this by printing out every coll visited to make sure that the robot gets to all of them D. find the coins Finally, you need to put in a check while the robot is traversing the world to see it finds the coins. You make the design decision about how to do that. Every time the robot find a con, it should print out a message the I am at (2.0) and I found the first con im gonna be rich Yippee! correctly inzed or call forward to verify that forward works as you expect Do the same with two, tumew),290) and zag. Again, this mains for Posting, not for submission 5 of 5 nocity the maint) so that the robot traverses its wort, staring at (0.0y and ending Visiting every cell 0.9 10. space fie al 100 cells). Unit test this by printing out cell visited to make sure that the robot gets to all of them D. find the coins Finally, you need to put in a check while the robot is braversing the world to see if finds the com. You make the design decision about how to do that. Every time the robot finds a con, it should point out a message the amat 2.0) and I found the first con 'm gonna be richt opeet Keep a count of how many moves the robot makes, and when the program exts, print a message saying how many moves the robot made Note: of course, traversing every call in tum is not an optimal search trategy by any means, but we will refine it later in the semester. The exercise here is to develop classes of your own with data and function members Extra: Make a Roomba robot E.marking rubric This assignment is worm 12 points. The breakdown is as follows: point class with two data members and ys and tour function members (print), set) gecXD and gy) (0.5 point world class with one data member coin) and two function members and se (0.5 poing robot class with two data members, enumerated type definition, and 12 function members in). print.setOneration), forward), tumCWD. tum dcWD. and westEnd, nortEnd) Southend,zago and 2) 13 points) - handing of commandine input or just inputs, including error handling (1 point complete traversal of the world by the robot (visiting every col unit all coins are found) (tpoint determining coins we found reporting when they are found and keeping track of how many have been found, including stopping when the 3rd coin is found points) counting and reporting the number of moves made by the robot ( peine Input Validation it point Documentation point

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain what the term third normal form (3NF) means.

Answered: 1 week ago

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

Create a workflow analysis.

Answered: 1 week ago