This assigment will give you the chance to practice passing arguments by reference.
In this lab, you will use pass-by-reference to effectively “return” multiple values from a single function. While doing this, you will also continue practicing loop design.
This week, your robot will be required to drive along a line that has other lines intersecting with it (see example to the right). These intersections, as shown, may be on one side or both. You must write C++ code to make the 3π robot:
Imagine that you are being driven along a road with many small towns on it. In this scenario, you cannot see out of the vehicle, but you can ask “are we currently in a town” as often as you like (and receive a truthful answer). Describe, in pseudocode, an algorithm for counting the number of towns that you are driven through.
Given a function
double temperature() that returns the current temperature
in degrees Celsius and a function
void pause() that pauses for ten minutes,
describe an algorithm (in pseudocode) that will count the number of times
the temperature crosses zero (from positive to negative or vice versa)
in a day.
Find the declaration for
lab5.zip’s engi1020.h and summarize what its purpose is,
what its parameters mean, and what its return value means.
It can be quite helpful to design your algorithm before you open Eclipse and start to write code. Specifically, you should design an algorithm that will make your robot:
When designing this algorithm, you should consider:
countIntersectionsfunction is called?
Create a stup (incomplete) implementation of
Ensure that the code compiles and can be downloaded to your 3$\pi$ robot, even though it doesn’t yet make the robot move.
You must define the
countIntersections function that has been declared
for you in
lab5.h and that you designed above.
Describe what you observed in this lab. What important techniques did you use to make your algorithms work correctly?
Once you have finished writing up your lab activity, submit your log book to the TAs in the lab. If you need extra time to finish the lab, you can submit your log book in the Engineering One Help Centre.