Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "class.h"
- #include <iostream>
- #include <iomanip>
- using namespace std;
- Cars::Cars() : model("Octavia"), gosnomer("B131AM"), familiya("Борисов"), color("Синий"), max_speed(180), places(4), lps(100)
- {
- }
- Cars::Cars(string mod, string gsn, string fam, string col, int ms, int p, int l):
- model(mod), gosnomer(gsn), familiya(fam), color(col), max_speed(ms), places(p), lps(l)
- {
- }
- Cars::Cars(const Cars& a)
- {
- model = a.model;
- gosnomer = a.gosnomer;
- familiya = a.familiya;
- color = a.color;
- max_speed = a.max_speed;
- places = a.places;
- lps = a.lps;
- }
- void Cars::get_all()
- {
- cout << setiosflags(ios::left) << setw(10) << model << setw(10) << gosnomer << setw(10) << familiya << setw(10) << color << setw(10) << max_speed <<
- setw(10) << places << setw(10) << lps << endl;
- }
- void Cars::get_model()
- {
- cout << model << endl;
- }
- void Cars::get_gosnomer()
- {
- cout << gosnomer << endl;
- }
- void Cars::get_familiya()
- {
- cout << familiya << endl;
- }
- void Cars::get_color()
- {
- cout << color << endl;
- }
- void Cars::get_max_speed()
- {
- cout << max_speed << endl;
- }
- void Cars::get_places()
- {
- cout << places << endl;
- }
- void Cars::get_lps()
- {
- cout << lps << endl;
- }
- void Cars::set_all()
- {
- cout << "Введите модель автомобиля: ";
- cin >> model;
- cout << "Ведите госномер: ";
- cin >> gosnomer;
- cout << "Введите фамилию водителя: ";
- cin >> familiya;
- cout << "Введите цвет автомобиля: ";
- cin >> color;
- cout << "Введите максимальную скорость автомобиля: ";
- cin >> max_speed;
- int_check(max_speed);
- cout << "Введите количество мест в автомобиле: ";
- cin >> places;
- int_check(places);
- cout << "Введите мощность двигателя: ";
- cin >> lps;
- int_check(lps);
- }
- void Cars::set_model()
- {
- cout << "Введите модель автомобиля: ";
- cin >> model;
- }
- void Cars::set_gosnomer()
- {
- cout << "Ведите госномер: ";
- cin >> gosnomer;
- }
- void Cars::set_familiya()
- {
- cout << "Введите фамилию водителя: ";
- cin >> familiya;
- }
- void Cars::set_color()
- {
- cout << "Введите цвет автомобиля: ";
- cin >> color;
- }
- void Cars::set_max_speed()
- {
- cout << "Введите максимальную скорость автомобиля: ";
- cin >> max_speed;
- int_check(max_speed);
- }
- void Cars::set_places()
- {
- cout << "Введите количество мест в автомобиле: ";
- cin >> places;
- int_check(places);
- }
- void Cars::set_lps()
- {
- cout << "Введите мощность двигателя: ";
- cin >> lps;
- int_check(lps);
- }
- void Cars::msoversmth(vector<Cars>& obj)
- {
- if (obj.size() - 1 == 0)
- {
- cout << "Нет автомобилей в списке." << endl;
- }
- if (obj.size() - 1 > 0)
- {
- string colors;
- int ms;
- cout << "Введите цвет автомобиля: ";
- cin >> colors;
- cout << "Введите максимальную скорость автомобиля: ";
- cin >> ms;
- int_check(ms);
- int j = 1;
- cout << setiosflags(ios::left) << setw(10) << "Модель" << setw(10) << "Госномер" <<
- setw(10) << "Фамилия" << setw(10) << "Цвет" << setw(10) << "Скорость" <<
- setw(10) << "Места" << setw(10) << "Мощность" << endl;
- palki();
- setlocale(LC_ALL, "Russian");
- for (int i = 0; i < obj.size() - 1; i++)
- {
- if (equal(obj[i].color, colors) && (ms < obj[i].max_speed))
- {
- cout << j++ << ".";
- obj[i].get_all();
- }
- }
- palki();
- }
- }
- void Cars::mestaoversmth(vector<Cars>& obj)
- {
- if (obj.size() - 1 == 0)
- {
- cout << "Нет автомобилей в списке." << endl;
- }
- if (obj.size() - 1 > 0)
- {
- int place;
- cout << "Введите количество мест: ";
- cin >> place;
- int_check(place);
- int j = 1;
- cout << setiosflags(ios::left) << setw(2) << " " << setw(10) << "Модель" << setw(10) << "Госномер" <<
- setw(10) << "Фамилия" << setw(10) << "Цвет" << setw(10) << "Скорость" <<
- setw(10) << "Места" << setw(10) << "Мощность" << endl;
- palki();
- for (int i = 0; i < obj.size() - 1; i++)
- {
- if (obj[i].places > place)
- {
- cout << j++ << ".";
- obj[i].get_all();
- }
- }
- palki();
- }
- }
- void Cars::int_check(int& number)
- {
- if (cin.fail())
- {
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- number = 0;
- }
- }
- bool Cars::equal(const string& a, const string& b)
- {
- if (a.size() != b.size())
- {
- return false;
- }
- for (int i = 0; i < a.size(); i++)
- {
- if (tolower(a[i]) != tolower(b[i]))
- {
- return false;
- }
- }
- return true;
- }
- void Cars::palki()
- {
- for (int i = 0; i < 72; i++)
- {
- cout << "-";
- }
- cout << endl;
- }
- Cars::~Cars()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment