Implementing program logic
Once a stub program has been created, we can proceed to replace stubs with working code.
Filling in the blanks
Now that we have code stubs and a map of each feature that needs to be implemented, we can begin writing the code logic. At this point, if you are working on a team, then this would be a good time to divide the work. The architecture phase may be done by one person, or as a team, but it can't be done in parallel. In contrast, the implementation phase can be broken into parts to work on separately.
Parsing input and storing as building description and floor requests
To parse input, we first need to decide whether to expect input from stdin
or from a file. We will adopt the convention that if a filename is provided to the program, then we will read from the file; if the file name is -
then read from stdin
, and otherwise read from test1.txt
.
Using the Rust std::env
package and a pattern match
statement, we can accomplish this quite easily. This is shown as follows...