SHARE
TWEET

задача из файла

a guest May 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<string>
  2. #include<iostream>
  3. #include<algorithm>
  4. using namespace std;
  5. class Bike {
  6. private:
  7.     string manufacturer;
  8.     string model;
  9.     string size;
  10.     string gender;
  11.     static int count;
  12. public:
  13.     Bike(){
  14.         ++count;
  15.     }
  16.     Bike(string manufacturer,string model,string size,string gender ) {
  17.         this->manufacturer = manufacturer;
  18.         this->model = model;
  19.         this->size = size;
  20.         this->gender = gender;
  21.         ++count;
  22.     }
  23.     void setManufacturer(string manufacturer) {
  24.         this->manufacturer = manufacturer;
  25.     }
  26.     void setModel(string model) {
  27.         this->model = model;
  28.     }
  29.     void setSize(string size) {
  30.         this->size = size;
  31.     }
  32.     void setGender(string gender) {
  33.         this->gender = gender;
  34.     }
  35.     void getManufacturer() {
  36.         cout << "Производитель: " << manufacturer << endl;
  37.     }
  38.     void getModel() {
  39.         cout << "Модель: " << model << endl;
  40.     }
  41.     void getSize() {
  42.         cout << "Размер: " << size << endl;
  43.     }
  44.     void getGender() {
  45.         cout << "Пол: " << gender << endl;
  46.     }
  47.     void getCount() {
  48.         cout << "Колличество: " << count << endl;
  49.     }
  50.     bool operator<(Bike a) {
  51.         if ((size == "s"&& a.size == "m") || (size == "s"&& a.size == "l") || (size == "s"&& a.size == "xl")) {
  52.             return 1;
  53.         }
  54.         else {
  55.             if ((size == "m"&& a.size == "l") || (size == "m"&& a.size == "xl")) {
  56.                 return 1;
  57.             }
  58.             else {
  59.                 if (size == "l"&& a.size == "xl") {
  60.                     return 1;
  61.                 }
  62.             }
  63.         }
  64.         if (size == a.size) {
  65.             if (manufacturer == a.manufacturer) {
  66.                 return(model < a.model);
  67.             }
  68.             else {
  69.                 return(manufacturer < a.manufacturer);
  70.             }
  71.         }
  72.  
  73.     }
  74.  
  75.  
  76. };
  77. int Bike::count = 0;
  78.  
  79. int main() {
  80.     setlocale(LC_ALL, "russian");
  81.     Bike stels("China","GF102","m","Male");
  82.     Bike stinger("China","XZ22C","m","Female");
  83.     Bike electra;
  84.     electra.setManufacturer("Russia");
  85.     electra.setModel("FS23");
  86.     electra.setSize("xl");
  87.     electra.setGender("Male");
  88.     cout << "Stels:" << endl;
  89.     stels.getManufacturer();
  90.     stels.getModel();
  91.     stels.getSize();
  92.     stels.getGender();
  93.     cout << "Stinger" << endl;
  94.     stinger.getManufacturer();
  95.     stinger.getModel();
  96.     stinger.getSize();
  97.     stinger.getGender();
  98.     cout << "Electra" << endl;
  99.     electra.getManufacturer();
  100.     electra.getModel();
  101.     electra.getSize();
  102.     electra.getGender();
  103.     cout << "Stels < Stinger ?" << endl;
  104.     if (stels < stinger) {
  105.         cout << "ДА"<<endl;
  106.     }
  107.     else {
  108.         cout << "НЕТ"<<endl;
  109.     }
  110.     system("pause");
  111.     return 0;
  112. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top