Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C5E1HouseBuilder.cpp : Defines the entry point for the console application.
- //Sebastian Lawe 12/5/2013 - Chapter 5 Exercise 1 - Builds a house.
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- //Declare enumerable.
- enum HouseSection{Roof, Base, Walk};
- //Declare function.
- void HouseBuilder(HouseSection section);
- int _tmain(int argc, _TCHAR* argv[])
- {
- //Call "HouseBuilder" to create roof.
- HouseBuilder(Roof);
- //Call "HouseBuilder" to create base.
- HouseBuilder(Base);
- //Call "HouseBuilder" to create walk.
- HouseBuilder(Walk);
- //Keep program from closing.
- std::getchar();
- return 0;
- }
- void HouseBuilder(HouseSection section){
- //Use switch statement to check what section must be built.
- switch(section){
- case Roof:
- //In the scenerio its a roof, print roof.
- cout<<" /\\ \n";
- cout<<" / \\ \n";
- cout<<"/____\\\n";
- break;
- case Base:
- //In the scenerio its a base, print base.
- cout<<"| |\n";
- cout<<"|____|\n";
- break;
- case Walk:
- //In the scenerio its a walk, print walk.
- cout<<" **\n";
- cout<<" *************\n";
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment