aboutsummaryrefslogtreecommitdiff
path: root/week08/Exercise6.cpp
blob: 22594a0e6bc319885e22688d9feb6c329d41a35a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "Exercise6.h"
#include <iostream>

NumberInput::NumberInput(int min, int max) {
	std::cout << "Enter number [" << min << ", " << max << "]: ";
	std::cin >> value;
	if (value < min || max < value) {
		throw "Number outside of range!";
	}
}

int NumberInput::GetValue() {
	return value;
}

int main() {
	while(true) {
		try {
			NumberInput a(5, 10);
			std::cout << a.GetValue() * 2 << std::endl;
			break;
		}
		catch (const char* error) {
			std::cout << error << std::endl;
		}
	}
}