/*

Copyright: 2000, All rights reserved.
Program: STL Strings 
Version: 1.1
Created/Revised: 
File: stlstrings.cpp
Programmer: C. S. Tritt, Ph.D.
Course: CS-150
Assignment: STL Strings Example
Compiler: Microsoft Visual C++ 6.0
Target: Win32

Description:

  This program demonstrates the use of C++ STL strings.
  The problem solved involves asking the user
  for a size code (L+, L, M, S and S-) and displying the
  corresponding text (Extra large, Large, Medium, Small
  and Extra small, respectively. This version also recognizes
  lower case letters.

  This program uses a somewhat odd approach for demonstration
  purposes.

Revisions:

  There have been no major revisions of this program.

Constants and Variables:

  See code for constant and variable descriptions.

*/

// Included files.

#include <iostream>
#include <string>

// Macros for ANSI C++ logical operations in MSVC++ 6.0.

#define and &&
#define or ||
#define not !

using namespace std;

int main()
{

	// Define constants.

   const string LARGE = "Ll"; // Change to Gg for European use.
   const string MEDIUM = "Mm";
   const string SMALL = "Ss"; // Change to Pp for European use.

   // Get input.

   cout << "Please enter a size code: ";
   string scode;
   cin >> scode;

   // Process input.

   cout << "Size: ";
   if (scode.length() > 2)
   {
      cout << "Invalid code: too many letters\n";
      return 1;
   }
   else if (scode.length() == 0)
   {
      cout << "Invalid code: too few letters\n";
      return 2;
   }
   else
   {
      if (scode[0] == LARGE[0] or scode[0] == LARGE[1])
      {
         if (scode.length() == 1) cout << "Large";
         else if (scode[1] == '+') cout << "Extra large";
         else
         {
            cout << "Invalid code: expecting \"+\"\n";
            return 3;
         }
      }
      else if (scode[0] == MEDIUM[0] or scode[0] == MEDIUM[1]) cout << "Medium";
      else if (scode[0] == SMALL[0] or scode[0] == SMALL[1])
      {
         if (scode.length() == 1) cout << "Small";
         else if (scode[1] == '-') cout << "Extra small";
         else
         {
            cout << "Invalid code: expecting \"-\"\n";
            return 4;
         }
      }
      else
      {
         cout << "Invalid code: unexpected letter.\n";
         return 5;
      }
   }
   cout << '\n';

   
   // Everything worked.

	return 0;
}