#include <iostream>
#include <string>
using namespace std;
class Mebel
{
private:
string manufacturer = "Не указано";
string type = "Не указано";
double price = 0;
public:
Mebel(string ma, string ty, double pr);
Mebel(string ma, string t);
Mebel(double pr);
Mebel(){};
~Mebel(){};
void input_ma()
getline(cin, manufacturer, '\n');
};
void input_ty()
getline(cin, type, '\n');
void input_ty(string ty)
type = ty;
void input_pr()
double pr;
cin >> pr;
price = pr;
string get_ma()
string ma = manufacturer;
return ma;
string get_ty()
string ty = type;
return ty;
double get_pr()
double pr = price;
return pr;
bool check_type(string ty2)
return (type == ty2);
bool check_price(double b, double d)
return (b <= price && price <= d);
Mebel::Mebel(string ma, string ty, double pr)
manufacturer = ma;
Mebel::Mebel(string ma, string t)
type = t;
Mebel::Mebel(double pr)
int main()
const int n = 3;
Mebel a[5];
for (int jjj = 0; jjj < n; jjj++)
cout << "Объект " << jjj + 1 << endl;
cout << "Производитель : ";
a[jjj].input_ma();
cout << "Тип мебели : ";
a[jjj].input_ty();
cout << "Цена : ";
a[jjj].input_pr();
cout << endl;
cin.clear();
cin.ignore(1000, '\n');
string str;
double pr1, pr2;
cin >> str;
cout << "Цена от ";
cin >> pr1;
cout << "до ";
cin >> pr2;
if (a[jjj].check_type(str) && a[jjj].check_price(pr1, pr2))
cout << "\nПроизводитель : " << a[jjj].get_ma() << "\nЦена : " << a[jjj].get_pr() << endl;
}:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <string>
using namespace std;
class Mebel
{
private:
string manufacturer = "Не указано";
string type = "Не указано";
double price = 0;
public:
Mebel(string ma, string ty, double pr);
Mebel(string ma, string t);
Mebel(double pr);
Mebel(){};
~Mebel(){};
void input_ma()
{
getline(cin, manufacturer, '\n');
};
void input_ty()
{
getline(cin, type, '\n');
};
void input_ty(string ty)
{
type = ty;
};
void input_pr()
{
double pr;
cin >> pr;
price = pr;
};
string get_ma()
{
string ma = manufacturer;
return ma;
};
string get_ty()
{
string ty = type;
return ty;
};
double get_pr()
{
double pr = price;
return pr;
};
bool check_type(string ty2)
{
return (type == ty2);
};
bool check_price(double b, double d)
{
return (b <= price && price <= d);
};
};
Mebel::Mebel(string ma, string ty, double pr)
{
manufacturer = ma;
type = ty;
price = pr;
};
Mebel::Mebel(string ma, string t)
{
manufacturer = ma;
type = t;
};
Mebel::Mebel(double pr)
{
price = pr;
};
int main()
{
const int n = 3;
Mebel a[5];
for (int jjj = 0; jjj < n; jjj++)
{
cout << "Объект " << jjj + 1 << endl;
cout << "Производитель : ";
a[jjj].input_ma();
cout << "Тип мебели : ";
a[jjj].input_ty();
cout << "Цена : ";
a[jjj].input_pr();
cout << endl;
cin.clear();
cin.ignore(1000, '\n');
};
string str;
double pr1, pr2;
cout << "Тип мебели : ";
cin >> str;
cout << "Цена от ";
cin >> pr1;
cout << "до ";
cin >> pr2;
for (int jjj = 0; jjj < n; jjj++)
if (a[jjj].check_type(str) && a[jjj].check_price(pr1, pr2))
cout << "\nПроизводитель : " << a[jjj].get_ma() << "\nЦена : " << a[jjj].get_pr() << endl;
}: