#include "poly.h"
#include <iostream.h>

// Menu class. You know this class
// -----------------------------------------------------------------------
class Menu
{
	public:
		int displayMenu();
};

int Menu::displayMenu()
{
	int d1 = 1;

	cout << "\nChoose one of the options from the menu:\n" << endl;

	cout << "[1]. Addition\n";
	cout << "[2]. Subtraction\n";
	cout << "[3]. Exit\n\n";
	
	do
	{
		if ( (d1<1) || (d1>3) )
		{
			cout << "Wrong Choice!!\n";
		}

		cout << "Enter your choice: ";
		cin >> d1;
	} while (d1 < 1 || d1 > 3);

	return d1;
}


// User choses one of the options from the menu. 
// -------------------------------------------------------------------------
int main()
{
	Polynom<expcoef> p1,p2,p3;
        int option;
	Menu mainMenu;
       
	do
	{
                p3.init(); 
		p1.init();
		p2.init();
		option = mainMenu.displayMenu();
		switch(option)
		{
			case 1:  // Addition
                                cout << "\nFor the first polynom:\n";
				p1.read();

                                cout << "\nFor the second polynom:\n";
			        p2.read();

				cout << "\nFirst polynom you entered is: ";
                                p1.print();
				
				cout << "Second polynom you entered is: ";
                                p2.print();

				
				p3=p1+p2;
 				
			        cout << "The result is: ";	
		        	p3.print();
				
				break;

			case 2: // Subtraction
                                cout<<"\nFor the first polynom:\n";
                                p1.read();
				
                                cout<<"\nFor the second polynom:\n";
                                p2.read();


				cout << "\nFirst polynom you entered is: ";
                                p1.print();
				
				cout << "Second polynom you entered is: ";
                                p2.print();
				
                                p3=p1-p2;
				
				cout<<"The result is: ";
                                p3.print();
 
				break;

				
		}
	} while (option != 3);

	return 0;
	
}

