

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Please perform the following activities. This assignment is unpledged. You may work with one other person in your laboratory session. You are allowed to talk with others, but your work must be your own.
We develop our first classes. The advantages of object-oriented design and implementation should become apparent.
The problem is identical to that described in homework V.
The Department of Energy (DOE) is in the process of developing a robot that can be used in hazardous environ- ments. The robot, HERO (Hazardous Environment Robot Observer), is controlled by simple commands. HERO understands the following commands:
When HERO executes a movement command (U, D, L, or R) it moves in that direction. It moves a distance that is specified by the last set movement distance command (M) executed. The speed command (S) tells HERO how fast to execute commands. The argument for the speed command is milliseconds. HERO delays n milliseconds before reading and executing the next command. Both the arguments to the speed and movement commands are integers.
To help DOE develop HERO, you have been asked to write a program that displays the actions of HERO. Your pro- gram reads a file of HERO commands and displays HERO’s action in a display window. Since HERO’s intended purpose is to find hazardous materials, the program should indicate when HERO encounters hazardous material. Whenever HERO crosses a region with hazardous material that region should be highlighted on the screen.
A HERO command file has the following format: 20.0 20. 9.0 9.0 2.0 2. 0.0 0. S 100 M 10 D D D D D D L
This first line is the width and height in centimeters of the display window. The second line is the coordinates of the hazardous waste region and the size (width and height) of the waste region. The third line is the starting coordinates of HERO. Following these three lines (which must be present in a HERO command file) are HERO commands.
Your program should open the command file hero.dat, create a display window of the indicated size, draw the haz- ardous waste region (which should be yellow), and draw HERO at its starting coordinates. To represent HERO on the display use a 1.0 centimeter by 1.0 centimeter blue square. The program should read HERO commands and update the display to simulate the movements of HERO. The program should terminate when the last command is executed.
When HERO enters the hazardous waste region, the region should be displayed as red. When HERO exits the haz- ardous waste region its color should be returned to yellow.
If HERO attempts to move beyond the boundary of the left edge of the display window, HERO should appear at the right edge of the display window. Similarly, if HERO attempts to move beyond the boundary of the right edge of the display window, HERO should appear at the left edge of the display window. When HERO is at the top or bottom edge of the display window, the action is similar. If HERO attempts to move beyond the top edge of the display win- dow, it should appear at the bottom of the display window. If HERO attempts to move beyond the bottom edge of the display window, it should appear at the top of the display window.
For this assignment we want to use object-oriented design and implementation techniques to realize a solution to the problem. If you analyze the above problem statement, clearly we need an object to represent the robot HERO and an object to represent the hazardous waste region. You should redo your solution using C++ classes that can be used to create HERO and a hazardous waste region. If you did Homework V using objects, then you are ahead of the game. However, you may wish to polish your solution.
You must show and turn a listing of your class declarations to your laboratory assistant during Laboratory X. Your laboratory assistant will give you some initial feedback on your class definitions. You need not submit your class dec- larations electronically.
Please submit your program electronically before the beginning of Laboratory XI. You should submit five files. The files to submit are:
robot.h Contains the class definition for the robot. robot.cpp Contains the implementation for the robot. hazard.h Contains the class definition for the hazardous waste region. hazard.cpp Contains the implementation for the hazardous waste region. hw06.cpp Contains the function ApiMain() and all other code needed to complete the assignment.