Advertisement
vencinachev

Shelter-main

Jun 18th, 2021
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <fstream>
  4. #include <string>
  5. #include "AnimalShelter.h"
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     Shelter myShelter;
  12.     Customer client;
  13.     ofstream shelterLog("shelterlog.txt");
  14.     while (true)
  15.     {
  16.         cout << "1. Enter new animal" << endl;
  17.         cout << "2. Buy animal" << endl;
  18.         cout << "3. Print all animals in the shelter" << endl;
  19.         cout << "4. Shelter info" << endl;
  20.         cout << "5. Add new animal place" << endl;
  21.         cout << "6. Exit" << endl;
  22.         int option;
  23.         cout << "Enter option: ";
  24.         cin >> option;
  25.         time_t now = time(0);
  26.         char* dt = ctime(&now);
  27.         switch (option)
  28.         {
  29.             case 1:
  30.                 if (myShelter.hasFreePlace())
  31.                 {
  32.                     myShelter.InsertAnimalInList(readAnimal());
  33.                     shelterLog << dt << ": ";
  34.                     shelterLog << "Added new animal to shelter" << endl;
  35.                 }
  36.                 else
  37.                 {
  38.                     cout << "There are no free place" << endl;
  39.                     shelterLog << dt << ": ";
  40.                     shelterLog << "Try to add new animal to shelter. No free places." << endl;
  41.                 }
  42.                 break;
  43.             case 2:
  44.                 client = Requirements();
  45.                 if (myShelter.IsFound(client))
  46.                 {
  47.                     myShelter.removeAnimalFromList(myShelter.GetAnimal(client));
  48.                     cout << "Congratulations! You buy an animal!" << endl;
  49.                     shelterLog << dt << ": ";
  50.                     shelterLog << "Bought animal from shelter." << endl;
  51.                 }
  52.                 else
  53.                 {
  54.                     cout << "Animal with this requirements not found!" << endl;
  55.                     shelterLog << dt << ": ";
  56.                     shelterLog << "Try to buy animal from shelter. Requirements not found!" << endl;
  57.                 }
  58.                 break;
  59.             case 3:
  60.                 myShelter.printShelter();
  61.                 shelterLog << dt << ": ";
  62.                 shelterLog << "Printing animals." << endl;
  63.                 break;
  64.             case 4:
  65.                 myShelter.shelterInfo();
  66.                 shelterLog << dt << ": ";
  67.                 shelterLog << "Printing shelter info." << endl;
  68.                 break;
  69.             case 5:
  70.                 myShelter.increaseFreePlases();
  71.                 cout << "Plases increased!" << endl;
  72.                 shelterLog << dt << ": ";
  73.                 shelterLog << "New place for animal!" << endl;
  74.                 break;
  75.             case 6:
  76.                 cout << "Bye, bye!" << endl;
  77.                 exit(1);
  78.                 break;
  79.             default:
  80.                 cout << "Invalid option! Try again." << endl;
  81.                 break;
  82.         }
  83.         system("pause");
  84.         system ("CLS");
  85.     }
  86.     shelterLog.close();
  87.     return 0;
  88. }
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement