text: ﻿// stacktem.cpp — тестирование шаблонного класса стека 
  //#include "stdafx.h" --- Visual Studio --- precompiled headers
  #include <iostream>
  #include <string>
  #include <cctype>
  #include "14.13_stacktp.h"
  
  using std::cin;
  using std::cout;
  
  //-------------------------------------------------------------------------------------------------
  int main()
  {
  	Stack<std::string> st;   // создание пустого стека 
  	char ch;
  	std::string po;
  	cout << "Please enter A to add a purchase order,\n"
  		 << "P to process a PO, or Q to quit.\n";
  	while (cin >> ch && std::toupper(ch) != 'Q')
  	{
  		while (cin.get() != '\n')
  			continue;
  		if (!std::isalpha(ch))
  		{
  			cout << '\a';
  			continue;
  		}
  		switch (ch)
  		{
  		case 'A':
  		case 'a': cout << "Enter a PO number to add: ";
  			cin >> po;
  			if (st.isfull())
  				cout << "stack already full\n";
  			else
  				st.push(po);
  			break;
  		case 'P':
  		case 'p': if (st.isempty())
  			cout << "stack already empty\n";
  				  else {
  					  st.pop(po);
  					  cout << "PO #" << po << " popped\n";
  					  break;
  				  }
  		}
  		cout << "Please enter A to add a purchase order,\n"
  			<< "P to process a PO, or Q to quit.\n";
  	}
  	cout << "Bye\n";
  
  	std::cin.get();
  	std::cin.get();
  	return 0;
  }
  //-------------------------------------------------------------------------------------------------
  /*
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  A
  Enter a PO number to add: red911porsche
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  A
  Enter a PO number to add: blueR8audi
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  A
  Enter a PO number to add: silver747boeing
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  P
  PO #silver747boeing popped
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  p
  PO #blueR8audi popped
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  P
  PO #red911porsche popped
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  p
  stack already empty
  Please enter A to add a purchase order,
  P to process a PO, or Q to quit.
  Q
  Bye
  */