SOURCE FILE: candyClmnTD_L2.cpp
#include<iostream>
using namespace std ;
void PrintInfoForUser() ;
int GetUserValue () ;
bool IsBadValue (int value);
void PrintErrorMessage (int badValue) ;
void MakeCandyColumn (int numCandies) ;
int main()
{
PrintInfoForUser() ;
int numM = GetUserValue() ;
if ( IsBadValue(numM) )
PrintErrorMessage(numM) ;
else MakeCandyColumn(numM) ;
return 0 ;
}
void PrintInfoForUser()
{
cout << "\nThis program has a sweet theme.\n" ;
cout << "It uses ASCII art to make a column of candy. You may\n" ;
cout << "request a column containing between 1 and 6 M candies.\n\n" ;
}
int GetUserValue ()
{
int value ;
cout << "How many Ms would you like to see? ===> " ;
cin >> value ;
return value ;
}
bool IsBadValue (int value)
{
if ( (value < 1 ) || (value > 6) )
return true ;
else return false ;
}
void PrintErrorMessage (int badValue )
{
cout << endl ;
if ( badValue < 0 )
cout << "Negative: bad value.\n" ;
else if ( badValue == 0 )
cout << "Zero: bad value.\n" ;
else /* case where badValue > 6 */
cout << "More than six: bad value.\n" ;
cout << endl ;
}
void MakeOneM () ;
void MakeBase() ;
void MakeCandyColumn (int numCandies)
{
cout << endl ;
for (int i = 1; i<=numCandies; i++)
MakeOneM() ;
MakeBase() ;
cout << endl ;
}
void MakeOneM ()
{
/* stub code */
cout << "Function MakeOneM executes\n" ;
}
void MakeBase()
{
/* stub code */
cout << "Function MakeBase executes\n" ;
}