From 83939d8584595c2ecf540efbf67d6ac8163408b5 Mon Sep 17 00:00:00 2001 From: Dmitry Kokorin Date: Mon, 29 Feb 2016 23:53:09 +0300 Subject: [PATCH] food_chain: variables are renamed --- cpp/food-chain/food_chain.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/cpp/food-chain/food_chain.cpp b/cpp/food-chain/food_chain.cpp index 4e7f2fb..10e4b85 100644 --- a/cpp/food-chain/food_chain.cpp +++ b/cpp/food-chain/food_chain.cpp @@ -1,12 +1,10 @@ #include "food_chain.h" -#include - namespace food_chain { using namespace std; -#define ANIMAL_TABLE \ +#define VERSE_TABLE \ X(Fly, "fly", "") \ X(Spider, "spider", "It wriggled and jiggled and tickled inside her.\n") \ X(Bird, "bird", "How absurd to swallow a bird!\n") \ @@ -17,20 +15,20 @@ X(Cow, "cow", "I don't know how she swallowed a cow!\n") \ X(Horse, "horse", "She's dead, of course!\n") #define X(a, b, c) a, -enum Animal { - ANIMAL_TABLE +enum Verse { + VERSE_TABLE }; #undef X #define X(a, b, c) b, -static const char *animal_name[] = { - ANIMAL_TABLE +static const char *food_name[] = { + VERSE_TABLE }; #undef X #define X(a, b, c) c, static const char *verse_phrase[] = { - ANIMAL_TABLE + VERSE_TABLE }; #undef X @@ -42,20 +40,20 @@ string verse(int index) --index; result += string("I know an old lady who swallowed a ") - + animal_name[index] + + food_name[index] + ".\n" + verse_phrase[index]; - if (index != Animal::Horse) { + if (index != Verse::Horse) { - for (int i = index; i > Animal::Fly; --i) { + for (int i = index; i > Verse::Fly; --i) { result += string("She swallowed the ") - + animal_name[i] + + food_name[i] + " to catch the " - + animal_name[i-1]; + + food_name[i-1]; - if (i == Animal::Bird) + if (i == Verse::Bird) result += string(" that wriggled and jiggled and " "tickled inside her");