Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- void drawAChristmasTree();
- cout << "Peter Fletcher - Adams - Due 11 December 2018 \n \n";
- drawAChristmasTree();
- system("pause");
- return 0;
- }
- void drawAChristmasTree()
- {
- void getValidHeight(int&);
- void drawFoliage(int&, int&);
- void drawTrunk(int&);
- int treeHeight, branch;
- getValidHeight(treeHeight);
- drawFoliage(treeHeight, branch);
- drawTrunk(branch);
- }
- void getValidHeight(int& height)
- {
- const int MinSize = 4;
- const int MaxSize = 20;
- cout << "Enter the size of the tree (4-20): ";
- cin >> height;
- while ((height > MaxSize) || (height < MinSize))
- {
- cout << "Invalid height! Enter the size of the tree (4-20): ";
- cin >> height;
- }
- }
- void drawFoliage(int& height, int& branch)
- {
- void drawALineOfFoliage(int& ,int&);
- int branchLine(1);
- do
- {
- drawALineOfFoliage(height, branch);
- branchLine = branchLine + 1;
- }
- while (branchLine <= (height - 2));
- }
- void drawALineOfFoliage(int& height, int& branch)
- {
- const char LEAF = '#';
- //char randomDecoration;
- int width(1 + (branch * 2));
- for (int f = 0; f < (height - branch - 2); f++)
- {
- cout << " ";
- }
- for (int f = 0; f < width; f++)
- {
- cout << "#";
- }
- cout << "\n";
- }
- void drawTrunk(int& height)
- {
- int trunkLine, spaces;
- const char BLANK = ' ';
- const char WOOD = '|';
- trunkLine = 1;
- do
- {
- spaces = 1;
- do
- {
- cout << BLANK;
- } while (spaces <= height - 2);
- cout << WOOD << "\n";
- trunkLine = trunkLine + 1;
- } while (trunkLine <= 2);
- }
- /*char randomDecoration()
- {
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement