Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Sem4 / Sem4 / Sem4

.cpp
Скачиваний:
0
Добавлен:
10.04.2019
Размер:
4.24 Кб
Скачать
яю// Sem4.cpp: >?@545;O5B B>G:C 2E>40 4;O :>=A>;L=>3> ?@8;>65=8O.

//



#include "stdafx.h"

#include "Base.h"

#include "Text.h"

#include "Picture.h"

#include "Formula.h"

#include <cmath>

#include <iostream>



using namespace std;



template <typename type>

void Valid(type& a)							//?@>25@:0 22>40

{

	while (true)

	{

		cin.clear(); //2>AAB0=02;8205B ?>B>: 

		cin.sync(); // >G8AB:0 1CD5@0 

		cin >> a;

		if (cin.good())

		{

			cin.ignore(10, '\n');		//83=>@8@>20=85 ";8H=8E" A8<2>;>2

			break;

		}

		cin.clear();

		cout << "Enter the correct data" << endl;

		cin.ignore(10, '\n');

	}

}



int main()

{

	Base B;

	double w, h;

	cout << "Enter the document width: ";

	Valid(w);

	cout << "Enter the document height: ";

	Valid(h);

	B.SetLH(w, h);

	

	char a = 'y';

	while (a == 'y')

	{

		char choose;

		cout << "What you want to create?\n"

			<< "1. Text\n"

			<< "2. Picture\n"

			<< "3. Formula\n";

		cin >> choose;

		switch (choose)

		{

		case '1':

		{

			Text T;

			int n;

			double h, l_space;

			int povt = -1;

			while (povt == -1)

			{

				cout << "\nEnter the number of the symbols: ";

				Valid(n);

				cout << "Enter the height of the symbols: ";

				Valid(h);

				cout << "Enter the line spacing: ";

				Valid(l_space);

				povt = T.Set(n, h, l_space, B);

			}

			double h_text = T.GetH_Text();

			B.ChangeOstH(h_text);										//2KG8A;5=85 >AB02H53>AO <5AB0

		}

		break;

		case '2':

		{

			Picture P;

			double h, l;

			int povt = -1;

			while (povt == -1)

			{

				cout << "\nEnter the image height: ";

				Valid(h);

				cout << "Enter the image width: ";

				Valid(l);

				povt = P.Set(l, h, B);

			}

			B.ChangeOstH(h);

		}

		break;

		case '3':

		{

			Formula F;

			double h, l;

			int povt = -1;

			while (povt == -1)

			{

				cout << "\nEnter the image height: ";

				Valid(h);

				cout << "Enter the image width: ";

				Valid(l);

				povt = F.Set(l, h, B);

			}

			B.ChangeOstH(h);

		}

		break;

		default:

			break;

		}

		cout << "Do you want to continue? (y/n)";

		cin >> a;

	}

    return 0;

}



Соседние файлы в папке Sem4