Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <clocale>
- #include <windows.h>
- using namespace std;
- template <typename Type>
- Type MagicInput(Type imputNumber) // Ввод с проверкой
- {
- while (!(cin >> imputNumber) || (cin.peek() != '\n'))
- {
- cin.clear();
- while (cin.get() != '\n');
- cout << "Ошибка ввода. Попробуйте еще раз.\n";
- }
- return imputNumber;
- }
- void SetLucidaFont()
- {
- HANDLE hCon = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- if (hCon != INVALID_HANDLE_VALUE) {
- CONSOLE_FONT_INFOEX cfi;
- cfi.cbSize = sizeof(CONSOLE_FONT_INFOEX);
- cfi.nFont = 0;
- cfi.dwFontSize.X = 0;
- cfi.dwFontSize.Y = 12;
- cfi.FontFamily = FF_DONTCARE;
- cfi.FontWeight = 400;
- wcscpy_s(cfi.FaceName, L"Lucida Console");
- SetCurrentConsoleFontEx(hCon, FALSE, &cfi);
- }
- }
- class House
- {
- private:
- string Address;
- int Floor;
- int RoomsCount;
- float Area;
- public:
- House() : Address("Улица Пушкина, дом Колотушкина."), Floor(1), RoomsCount(1), Area(1) {};
- void Show()
- {
- cout << endl << "Адресс: " << Address << "; этаж: " << Floor << "; количество комнат: " << RoomsCount << "; площадь: " << Area;
- }
- string getAddress() { return Address; }
- int getFloor() { return Floor; }
- int getRoomsCount() { return RoomsCount; }
- float getArea() { return Area; }
- void setAddress(string address) { Address = address; }
- void setFloor(int floor) { Floor = floor; }
- void setRoomsCount(int roomsCount) { RoomsCount = roomsCount; }
- void setArea(float area) { Area = area; }
- };
- void main()
- {
- SetLucidaFont();
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- House house;
- cout << "Введите адресс: " ;
- string address;
- getline(cin, address);
- house.setAddress(address);
- cout << endl << "Введите этаж: ";
- house.setFloor(MagicInput((int)0));
- cout << endl << "Введите количество комнат: ";
- house.setRoomsCount(MagicInput((int)0));
- cout << endl << "Введите площадь: ";
- house.setArea(MagicInput((float)0));
- house.Show();
- cout << endl << endl << "ESC - Выход";
- while (!GetAsyncKeyState(VK_ESCAPE)){}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement