We will add some more pieces to our program. All of these additions should still be in your same .cpp file. You should expect to keep building in this file through the end of the project.
In Chapter 6, we will learn how to write our own functions. You may not know how to do this yet, but if there is some logic you think should stand by itself, feel free to 'hack' some draft functions. As an example, if you expect to have an operation to count jelly beans, you can put a simple placeholder for your function like this:
int CountJellyBeans() {
// get the bunch of jelly beans
// declare a counter variable and set it to zero
// go to the first jelly bean
// REPEAT THIS
// add one to the counter variable
// go to the next bean
// REPEAT LAST STEP IF MORE BEANS
// When no more beans return the counter
}
Here are some functions you may want to build at some time or another:
- calculate the apogee for a rocket launch
- get the user's next move in the adventure game
- draw the battleship map
- generate a problem to solve
- store the user's text in a file
There are any number of things that you can put into a function. As you go, I can help you set these up effectively.
And yes, again, the file still doesn't do anything. Compile it anyway.
OPTIONAL You do not have to do this, but it could be a useful milestone for you, and allows me the opportunity to give you feedback when I can