OOP-Project-main/.gitignore # Visual Studio *.sdf *.sln *.user *.suo *.opensdf *.db Debug/ ipch/ x64/ .vs/ #tempfiles ~$_*.* #codelite .clang/ .codelite/ Debug/ # Prerequisites *.d # Compiled Object...

1 answer below »
Want to get the full solution for this project


OOP-Project-main/.gitignore # Visual Studio *.sdf *.sln *.user *.suo *.opensdf *.db Debug/ ipch/ x64/ .vs/ #tempfiles ~$_*.* #codelite .clang/ .codelite/ Debug/ # Prerequisites *.d # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod *.smod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app OOP-Project-main/MS1/Time.cpp #include "Time.h" #include "utils.h" using namespace std; namespace sdds { } OOP-Project-main/MS1/Time.h #ifndef SDDS_TIMER_H #define SDDS_TIMER_H #include namespace sdds { class Time { unsigned int m_min; public: Time& setToNow(); Time(unsigned int min = 0); std::ostream& write(std::ostream& ostr) const; std::istream& read(std::istream& istr); Time& operator-=(const Time& D); Time operator-(const Time& D)const; Time& operator+=(const Time& D); Time operator+(const Time& D)const; Time& operator=(unsigned int val); Time& operator *= (unsigned int val); Time& operator /= (unsigned int val); Time operator *(unsigned int val)const; Time operator /(unsigned int val)const; operator unsigned int()const; operator int()const; }; std::ostream& operator<(std::ostream& ostr,="" const="" time&="" d);="" std::istream&="" operator="">>(std::istream& istr, Time& D); } #endif // !SDDS_TIME_H OOP-Project-main/MS1/images/time.png OOP-Project-main/MS1/ms1.vcxproj Debug Win32 Release Win32 Debug x64 Release x64 16.0 Win32Proj {ac052bfa-c1e0-41ad-bc64-6ec78e375eb3} ms1 10.0 Application true v142 Unicode Application false v142 true Unicode Application true v142 Unicode Application false v142 true Unicode true false true false Level3 true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true Console true Level3 true true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true Console true true true Level3 true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true Console true Level3 true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true Console true true true OOP-Project-main/MS1/ms1.vcxproj.filters {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files Source Files Source Files Header Files Header Files OOP-Project-main/MS1/ms1Tester.cpp OOP-Project-main/MS1/ms1Tester.cpp // ms1 Tester: // Version: 1.0 // Date: 2021-06-23 // Author: Fardad Soleimanloo // Description: // This file tests the utils and Time Module of your project ///////////////////////////////////////////// #include  #include "utils.h" #include "utils.h" #include "Time.h" #include "Time.h" using namespace std; using namespace sdds; void getIntTester(); void timeTester(); void getcstrTester(); int main() {    getIntTester();    getcstrTester();    timeTester();    return 0; } void getIntTester() {    cout <>< endl;>< "enter 11: ";><><>< endl;><>< endl;><>" < endl;><>" < endl;><> (there is a space after 9)" < endl;><>" < endl;>< getint("> ") <>< endl;><>< endl;><>" < endl;><>" < endl;><>" < endl;><>" < endl;><> (there is a space after 21)" < endl;><>" < endl;    getint(10, 20, "=""> ", "Value must be between 10 and 20: ", false);    // fixed compiler version dependency :    int val = getInt(10, 20, "> ", "Invalid value, retry ");    cout <><>< endl; }="" void timetester() {=""    time d(1385u), c(65u), e;=""><><>< endl;><><>< endl;><><>< endl;><>< endl;><><><>< " = ";><><>< endl;><>< endl;><><><>< " = ";><><>< endl;><>< endl;><><><>< " = ";><><>< endl;><>< endl;><><><>< endl;><>< endl;><><><>< endl;><>< endl;    e =" C + D;"><><><><><><>< endl;><>< endl;    e =" C - D;"><><><><><><>< endl;><><>< endl;><><>< "c: ";><>< endl;><><>< "c: ";><><>< endl;><>< endl;><><><>< endl;><>< endl;    e =" C * 2u;"><><><><><>< endl;><>< endl;    e =" C * 12u;"><><><><><>< endl;><><>< endl;>< " c ><>< "c: ";>< (c >< endl;><>< endl;><><><>< endl;>< "  e   =   c   >< endl;    e =" C / 2u;"><><><>< " ><>< endl;><><>< endl;><><>< endl;><><><>< endl;><>< endl;><>" < endl;><>" < endl;><>" < endl;><>< endl;><>< endl;>< "please enter the time (hh:mm): ";    bool done;=""    do {=""       done =" true;"       cin ="">> E;       if (cin.fail()) {          cin.clear();          cin.ignore(1000, '\n');          done = false;          cout < "bad time entry, retry (hh:mm): ";       }=""    } while (!done);=""><><><>< endl;><>< endl;    sdds::debug =" true;"    e.settonow();=""><>< endl;    sdds::debug =" false;"><><>< endl; }="" void getcstrtester() {=""    char* cstr;=""><>< endl;>< "if you didn't care what happened to me, "       "and i didn't care for you, "=""       "we would zig zag our way through the boredom and pain, "=""       "occasionally glancing up through the rain. "=""       "wondering which of the brothers to blame. "="">< endl;    cstr =" getcstr("Paste here /"> ");    cout <><><>< endl;    delete[] cstr;="" }="" oop-project-main/ms1/utils.cpp="" oop-project-main/ms1/utils.cpp="" #define _crt_secure_no_warnings=""> #include  #include  #include  #include  #include "utils.h" #include "Time.h" using namespace std; namespace sdds {    bool debug = false;  // made global in utils.h    int getTime() {         int mins = -1;       if (debug) {          Time t(0);          cout < "enter current time: ";          do {=""             cin.clear();=""             cin ="">> t;   // needs extraction operator overloaded for Time             if (!cin) {                cout < "invlid time, try agian (hh:mm): ";                cin.clear();=""             }=""             else {=""                mins =" int(t);"             }=""             cin.ignore(1000, '\n');="">< 0);       }=""       else {=""          time_t t =" time(NULL);"          tm lt =" *localtime(&t);"          mins =" lt.tm_hour * 60 + lt.tm_min;"       }=""       return mins;=""    }="" }="" oop-project-main/ms1/utils.h="" #ifndef="" sdds_utils_h_="" #define="" sdds_utils_h_="" #include=""> namespace sdds { extern bool debug; // making sdds::debug variable global to all the files // which include: "utils.h" int getTime(); // returns the time of day in minutes } #endif // !SDDS_UTILS_H_ OOP-Project-main/MS2/IOAbleTester.cpp OOP-Project-main/MS2/IOAbleTester.cpp // IOAble Tester: // Version: 1.0 // Date: 2021-06-23 // Author: Fardad Soleimanloo // Description: // This file tests the IOAble Module of your project ///////////////////////////////////////////// #include  #include  #include "IOAble.h" using namespace std; using namespace sdds; void displayFile(const char* filename) {    ifstream file(filename);    cout <><>< endl;    char ch;="">< ch);><>< endl; }="" class box :public ioable {=""    int m_hieght, m_width;="" public:=""    bool csv;=""    box() :m_hieght(0), m_width(0), csv(false) {=""><>< endl;    };=""    ostream& csvwrite(std::ostream& ostr)const {=""><><>< m_width;    }=""    istream& csvread(std::istream& istr) {=""       istr ="">> m_hieght;       istr.ignore();       istr >> m_width;       istr.ignore();       return istr;    }    ostream& write(ostream& ostr)const {       if (csv) {          csvWrite(ostr);       }       else {          int i;          for (int j = 0; j < m_hieght; j++) {             for (i =""><>< "*");>< endl;          }=""       }=""       return ostr;=""    }=""    istream& read(istream& istr) {=""       if (csv) {=""          csvread(istr);=""       }=""       else {="">< "height: ";          istr ="">> m_hieght;          cout < "width: ";          istr ="">> m_width;       }       return istr;    }    ~Box() {       cout <><><><><>< endl;    }="" };="" int main() {=""    box b;=""><>< endl;    cin ="">> B;    cout <>< endl;><>< endl;    b.csv =" false;"    ifstream fboxes("boxes.txt");=""    if (fboxes) {=""       box* bp;=""       ofstream bout("boxesout.txt");=""       b.csv =" true;"><><><>< endl;><>< endl;><>< endl;       ioable* iop =" Bp = new Box();"><>< endl;;       bp-="">csv = true;       fboxes >> *iop;       cout <>< endl;><>< endl;       bp-="">csv = false;       cout <><><>< endl;       bp-="">csv = true;       cout <>< endl;><>< endl;><>< endl;;       fboxes ="">> *iop;       cout <>< endl;><>< endl;       bp-="">csv = false;       cout <><><>< endl;       bp-="">csv = true;       cout <>< endl;><>< endl;><>< endl;       bout.close();=""       displayfile("boxesout.txt");=""><>< endl;       delete bp;=""       bout.close();=""    }=""    else {=""><>< endl;    }=""><>< endl;    displayfile("boxesout.txt");=""    return 0;="" }="" oop-project-main/ms2/boxes.txt="" 5,7="" 7,4="" oop-project-main/ms2/images/classes.png="" oop-project-main/ms2/images/time.png="" oop-project-main/ms2/menutester.cpp="" oop-project-main/ms2/menutester.cpp=""  menu tester:=""  version: 1.0=""  date: 2021-06-23=""  author: fardad soleimanloo=""  description:=""  this file tests the menu module of the project=""> #include "Menu.h" using namespace sdds; using namespace std; void menuTester(Menu m) {    int selection;    while (m >> selection) {       switch (selection) {       case 1:          cout <><>< endl;          break;=""       case 2:=""><><>< endl;          break;=""       case 3:=""><><>< endl;          break;=""       default:=""><>< endl;          break;=""       }=""    }=""><>< endl; } int main() {    menu m("tester options menu:\n1- option one\n2- option two\n3- option three", 3);    menutester(m);    return 0; } oop-project-main/ms2/ms2.vcxproj debug win32 release win32 debug x64 release x64 16 }="" int main() {=""    menu m("tester options menu:\n1- option one\n2- option two\n3- option three", 3);=""    menutester(m);=""    return 0;="" }="" oop-project-main/ms2/ms2.vcxproj="" debug="" win32="" release="" win32="" debug="" x64="" release="" x64="">
Answered 4 days AfterAug 08, 2021

Answer To: OOP-Project-main/.gitignore # Visual Studio *.sdf *.sln *.user *.suo *.opensdf *.db Debug/ ipch/...

Pulkit answered on Aug 13 2021
161 Votes
OOP-Project-main/.gitignore
# Visual Studio
*.sdf
*.sln
*.user
*.suo
*.opensdf
*.db
Debug/
ipch/
x64/
.vs/
#tempfiles
~$_*.*
#codelite
.clang/
.codelite/
Debug/
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
OOP-Project-main/MS1/images/time.png
OOP-Project-main/MS1/ms1.vcxproj



Debug
Win32


Release
Win32


Debug
x64


Release
x64



16.0
Win32Proj
{ac052bfa-c1e0-41ad-bc64-6ec78e375eb3}
ms1
10.0



Application
true
v142
Unicode


Application
false
v142
true
Unicode


Application
true
v142
Unicode


Application
false
v142
true
Unicode




















true


false


true


false



Level3
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true




Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true














OOP-Project-main/MS1/ms1.vcxproj.filters



{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx


{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd


{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms




Source Files


Source Files


Source Files




Header Files


Header Files


OOP-Project-main/MS1/ms1Tester.cpp
OOP-Project-main/MS1/ms1Tester.cpp
// ms1 Tester:
// Version: 1.0
// Date: 2021-06-23
// Author: Fardad Soleimanloo
// Description:
// This file tests the utils and Time Module of your project
/////////////////////////////////////////////
#include 
#include "utils.h"
#include "utils.h"
#include "Time.h"
#include "Time.h"
using namespace std;
using namespace sdds;
void getIntTester();
void timeTester();
void getcstrTester();
int main() {
   getIntTester();
   getcstrTester();
   timeTester();
   return 0;
}
void getIntTester() {
   cout << "getInt tester:" << endl;
   cout << "Enter 11: ";
   cout << getInt() << endl << endl;
   cout << "Enter the following values at the prompt: " << endl;
   cout << "abc" << endl;
   cout << "9abc" << endl;
   cout << "9  (there is a space after 9)" << endl;
   cout << "9" << endl;
   cout << getInt("> ") << endl << endl;
   cout << "Enter the following values at the prompt: " << endl;
   cout << "abc" << endl;
   cout << "9" << endl;
   cout << "10" << endl;
   cout << "21" << endl;
   cout << "21  (there is a space after 21)" << endl;
   cout << "20" << endl;
   getInt(10, 20, "> ", "Value must be between 10 and 20: ", false);
   // fixed compiler version dependency :
   int val = getInt(10, 20, "> ", "Invalid value, retry ");
   cout << "last value entered: " << val << endl;
}
void timeTester() {
   Time D(1385u), C(65u), E;
   cout << "E: " << E << endl;
   cout << "D: " << D << endl;
   cout << "C: " << C << endl;
   cout << "  D        C     D-=C" << endl;
   cout << D << " -= " << C << " = ";
   cout << (D -= C) << endl << endl;
   cout << "  C        D     C-=D" << endl;
   cout << C << " -= " << D << " = ";
   cout << (C -= D) << endl << endl;
   cout << "  C        D     C+=D" << endl;
   cout << C << " += " << D << " = ";
   cout << (C += D) << endl << endl;
   cout << " C = 245u" << endl;
   cout << "C: " << (C = 245u) << endl << endl;
   cout << " D = 2760u" << endl;
   cout << "D: " << (D = 2760u) << endl << endl;
   cout << "  E   =   C   +   D" << endl;
   E = C + D;
   cout << E << " = " << C << " + " << D << endl << endl;
   cout << "  E   =   C   -   D" << endl;
   E = C - D;
   cout << E << " = " << C << " - " << D << endl << endl;
   cout << "C: " << C << endl;
   cout << " C *= 2u;" << endl << "C: ";
   cout << (C *= 2u) << endl;
   cout << " C *= 12u" << endl << "C: ";
   cout << (C *= 12u) << endl << endl;
   cout << " C = 245u" << endl;
   cout << "C: " << (C = 245u) << endl << endl;
   cout << "  E   =   C   *  2u" << endl;
   E = C * 2u;
   cout << E << " = " << C << " *  2u" << endl << endl;
   cout << "  E   =   C   *  12u" << endl;
   E = C * 12u;
   cout << E << " = " << C << " *  12u" << endl << endl;
   cout << "C: " << C << endl;
   cout << " C /= 2u;" << endl << "C: ";
   cout << (C /= 2u) << endl;
   cout << " C = 245u" << endl;
   cout << "C: " << (C = 245u) << endl << endl;
   cout << "  E   =   C   /  2u" << endl;
   E = C / 2u;
   cout << E << " = " << C << " /  2u" << endl << endl;
   cout << "E: " << E << endl;
   cout << "D: " << D << endl;
   cout << "C: " << C << endl << endl;
   cout << "Enter the following values at the prompt:" << endl;
   cout << "aa:bb" << endl;
   cout << "12,12TER>" << endl;
   cout << "-12:12" << endl;
   cout << "12:-12" << endl;
   cout << "12:12" << endl;
   cout << "Please enter the time (HH:MM): ";
   bool done;
   do {
      done = true;
      cin >> E;
      if (cin.fail()) {
         cin.clear();
         cin.ignore(1000, '\n');
         done = false;
         cout << "Bad time entry, retry (HH:MM): ";
      }
   } while (!done);
   cout << "you entered: " << E << endl << endl;
   cout << "Enter 100:100 at the prompt: " << endl;
   sdds::debug = true;
   E.setToNow();
   cout << E << endl;
   sdds::debug = false;
   cout << "The actual system time is: " << Time().setToNow() << endl;
}
void getcstrTester() {
   char* cstr;
   cout << "Copy and paste the following at the prompt:" << endl;
   cout << "If you didn't care what happened to me, "
      "And I didn't care for you, "
      "We would zig zag our way through the boredom and pain, "
      "Occasionally glancing up through the rain. "
      "Wondering which of the brothers to blame. "
      "And watching for pigs on the wing." << endl;
   cstr = getcstr("Paste here /> ");
   cout << "you entered:" << endl << cstr << endl;
   delete[] cstr;
}
OOP-Project-main/MS1/Time.cpp
#include "Time.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Time& Time::setToNow()
{
m_min = getTime();
return *this;
}
Time::Time(unsigned int min)
{
m_min = min;
}
std::ostream& Time::write(std::ostream &ostr) const
{
ostr.width(2);
ostr.fill('0');
ostr <<(m_min / 60);
ostr << ":";
ostr.width(2);
ostr.fill('0');
ostr << (m_min % 60);
return ostr;
}
std::istream& Time::read(std::istream &istr)
{
int _hour = 0;
int _min = 0;
char _delimiter;
istr >> _hour;
if (!istr) istr.setstate(ios::failbit);
else if (_hour < 0) istr.setstate(ios::failbit);
else {
istr >> _delimiter;
if (_delimiter != ':') istr.setstate(ios::failbit);
else {
istr >> _min;
if (_min < 0) istr.setstate(ios::failbit);
else m_min = (_hour * 60) + _min;
}
}
return istr;
}
Time& Time::operator-=(const Time &D)
{
if (this->m_min > D.m_min)
this->m_min -= D.m_min;
else
this->m_min = this->m_min + (1440 * ( (D.m_min / 1440) + 1)) - D.m_min;
return *this;
}
Time Time::operator-(const Time &D) const
{
Time temp;
if (this->m_min > D.m_min)
temp.m_min = this->m_min - D.m_min;
else
temp.m_min = this->m_min + (1440 * ((D.m_min / 1440) + 1)) - D.m_min;
return temp;
}
Time& Time::operator+=(const Time &D)
{
this->m_min += D.m_min;
return *this;
}
Time Time::operator+(const Time &D) const
{
Time temp;
temp.m_min = this->m_min + D.m_min;
return temp;
}
Time& Time::operator=(unsigned int val)
{
this->m_min = val;
return *this;
}
Time& Time::operator*=(unsigned int val)
{
this->m_min *= val;
return *this;
}
Time Time::operator*(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min * val;
return temp;
}
Time& Time::operator/=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operator/(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min / val;
return temp;
}
Time::operator int() const
{
return (int)m_min;
}
Time::operator unsigned int() const
{
return m_min;
}
std::ostream &operator<<(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operator>>(std::istream &istr, Time &D)
{
return D.read(istr);
}
}
OOP-Project-main/MS1/Time.h
#ifndef SDDS_TIMER_H
#define SDDS_TIMER_H
#include
namespace sdds {
class Time {
unsigned int m_min;
public:
Time& setToNow();
Time(unsigned int min = 0);
std::ostream& write(std::ostream& ostr) const;
std::istream& read(std::istream& istr);
Time& operator-=(const Time& D);
Time operator-(const Time& D)const;
Time& operator+=(const Time& D);
Time operator+(const Time& D)const;
Time& operator=(unsigned int val);
Time& operator *= (unsigned int val);
Time& operator /= (unsigned int val);
Time operator *(unsigned int val)const;
Time operator /(unsigned int val)const;
operator unsigned int()const;
operator int()const;
};
std::ostream& operator<<(std::ostream& ostr, const Time& D);
std::istream& operator>>(std::istream& istr, Time& D);
}
#endif // !SDDS_TIME_H
OOP-Project-main/MS1/utils.cpp
OOP-Project-main/MS1/utils.cpp
#define _CRT_SECURE_NO_WARNINGS
#include 
#include 
#include 
#include 
#include 
#include "utils.h"
#include "Time.h"
using namespace std;
namespace sdds {
   bool debug = false;  // made global in utils.h
   int getTime() {  
      int mins = -1;
      if (debug) {
         Time t(0);
         cout << "Enter current time: ";
         do {
            cin.clear();
            cin >> t;   // needs extraction operator overloaded for Time
            if (!cin) {
               cout << "Invlid time, try agian (HH:MM): ";
               cin.clear();
            }
            else {
               mins = int(t);
            }
            cin.ignore(1000, '\n');
         } while (mins < 0);
      }
      else {
         time_t t = time(NULL);
         tm lt = *localtime(&t);
         mins = lt.tm_hour * 60 + lt.tm_min;
      }
      return mins;
   }
   int getInt(const char *prompt)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  int getInt(int min, int max, const char *prompt,
             const char *errorMessage, bool showRangeAtError)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else if (_input < min || _input > max) {
          if (errorMessage) cout << errorMessage;
          if (showRangeAtError) cout << "[" << min << " <= value <= " << max << "]: ";
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  char *getcstr(const char *prompt, std::istream &istr, char delimiter)
  {
    char _input[BUFFER_SIZE];
    char *_outString;
    int _size = 0;
    int i     = 0;
    if (prompt) cout << prompt;
    istr.getline(_input, BUFFER_SIZE, delimiter);
    while (_input[_size] != '\0') _size++;
    _outString = new char[_size + 1];
    while (_input[i] != '\0') {
      _outString[i] = _input[i];
      i++;
    }
    _outString[i] = '\0';
    return _outString;
}
}
OOP-Project-main/MS1/utils.h
#ifndef SDDS_UTILS_H_
#define SDDS_UTILS_H_
#include
namespace sdds {
extern bool debug; // making sdds::debug variable global to all the files
// which include: "utils.h"
const int BUFFER_SIZE = 32767;
int getTime(); // returns the time of day in minutes
int getInt(const char *prompt = nullptr);

int getInt(int min, int max, const char *prompt = nullptr,
const char *errorMessage = nullptr, bool showRangeAtError = true);
char *getcstr(const char *prompt = nullptr, std::istream &istr = std::cin,
char delimiter = '\n');
}
#endif // !SDDS_UTILS_H_
OOP-Project-main/MS2/boxes.txt
5,7
7,4
OOP-Project-main/MS2/images/classes.png
OOP-Project-main/MS2/images/time.png
OOP-Project-main/MS2/IOAble.cpp
#include "IOAble.h"
using namespace std;
namespace sdds
{
std::ostream &operator<<(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operator>>(std::istream &istr, IOAble &src)
{
return src.read(istr);
}
}
OOP-Project-main/MS2/IOAble.h
#ifndef SDDS_IOABLE_H
#define SDDS_IOABLE_H
#include
namespace sdds
{
class IOAble
{
public:
virtual std::ostream &csvWrite(std::ostream &ostr) const = 0;
virtual std::istream &csvRead(std::istream &istr) = 0;
virtual std::ostream &write(std::ostream &ostr) const = 0;
virtual std::istream &read(std::istream &istr) = 0;
virtual ~IOAble() {};
};
std::ostream &operator<<(std::ostream &ostr, const IOAble &src);
std::istream &operator>>(std::istream &istr, IOAble &src);
}
#endif
OOP-Project-main/MS2/Menu.cpp
#include
#include "Menu.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Menu::Menu(const char *MenuContent, int NoOfSelections)
{
if (MenuContent && MenuContent[0] != '\0') {
m_text = new char[strlen(MenuContent) + 1];
strcpy(m_text, MenuContent);
}
NoOfSelections > 0 ? m_noOfSel = NoOfSelections : m_noOfSel = 0;
}
Menu::~Menu()
{
if (m_text) {
delete[] m_text;
m_text = nullptr;
}
}
void Menu::display() const
{
cout << m_text << endl;
cout << "0- Exit" << endl;
}
int& Menu::operator>>(int &Selection)
{
display();
return Selection = getInt(0, m_noOfSel, "> ", "Invalid option ");
}
Menu::Menu(const Menu &src)
{
this->m_noOfSel = src.m_noOfSel;
if (src.m_text) {
this->m_text = new char[strlen(src.m_text) + 1];
strcpy(this->m_text, src.m_text);
}
}
}
OOP-Project-main/MS2/Menu.h
#ifndef SDDS_MENU_H_
#define SDDS_MENU_H_
#include
namespace sdds
{
class Menu
{
char *m_text{nullptr};
int m_noOfSel{0};
void display() const;
public:
Menu(const char* MenuContent, int NoOfSelections);
virtual ~Menu();
int &operator>>(int& Selection);
Menu(const Menu &src);
Menu &operator=(const Menu &) = delete;
};
}
#endif
OOP-Project-main/MS2/ms2.vcxproj



Debug
Win32


Release
Win32


Debug
x64


Release
x64



16.0
Win32Proj
{15cb68c4-655d-4b4f-b19e-b6166fb07e74}
ms2
10.0



Application
true
v142
Unicode


Application
false
v142
true
Unicode


Application
true
v142
Unicode


Application
false
v142
true
Unicode




















true


false


true


false



Level3
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true




Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true


















OOP-Project-main/MS2/ms2.vcxproj.filters



{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx


{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd


{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms




Source Files


Source Files


Source Files


Source Files


Source Files




Header Files


Header Files


Header Files


Header Files


OOP-Project-main/MS2/ms2Tester.cpp
OOP-Project-main/MS2/ms2Tester.cpp
// IOAble Tester:
// Version: 1.0
// Date: 2021-06-23
// Author: Fardad Soleimanloo
// Description:
// This file tests the IOAble Module of your project
/////////////////////////////////////////////
#include 
#include 
#include "Menu.h"
#include "IOAble.h"
using namespace std;
using namespace sdds;
class Box :public IOAble {
   int m_hieght, m_width;
public:
   bool csv;
   Box();
   ostream& csvWrite(std::ostream& ostr)const;
   istream& csvRead(std::istream& istr);
   ostream& write(ostream& ostr)const;
   istream& read(istream& istr);
   virtual ~Box();
};
void menuTester(Menu m);
void displayFile(const char* filename);
void IOAbleTester();
int main() {
   Menu m("Tester Options menu:\n1- Option one\n2- Option two\n3- Option three", 3);
   menuTester(m);
   IOAbleTester();
   return 0;
}
void IOAbleTester() {
   cout << "IOAble Tester ************************************" << endl;
   Box B;
   cout << "Getting information of an IOAble box from console: " << endl;
   cin >> B;
   cout << "Display the IOAble box on console: " << endl;
   cout << B << endl;
   B.csv = false;
   ifstream fboxes("boxes.txt");
   if (fboxes) {
      Box* Bp;
      ofstream bout("boxesOut.txt");
      B.csv = true;
      cout << "Saving " << B << " in the output file." << endl;
      bout << B << endl;
      cout << "Dynamically allocating a Box and holding it in an IOAble pointer..." << endl;
      IOAble* iop = Bp = new Box();
      cout << "Reading dimenstions from file using the IOAlbe pointer" << endl;;
      Bp->csv = true;
      fboxes >> *iop;
      cout << "Dimentions: " << endl;
      cout << *iop << endl;
      Bp->csv = false;
      cout << "What it looks like on screen:" << endl << *iop << endl;
      Bp->csv = true;
      cout << "Now save it in the file..." << endl;
      bout << *iop << endl;
      cout << "Reading the next dimenstions from file using the IOAble pointer" << endl;;
      fboxes >> *iop;
      cout << "Dimentions: " << endl;
      cout << *iop << endl;
      Bp->csv = false;
      cout << "What it looks like on screen:" << endl << *iop << endl;
      Bp->csv = true;
      cout << "Save this one in the output file too..." << endl;
      bout << *iop << endl;
      cout << "Close the file and display it..." << endl;
      bout.close();
      displayFile("boxesOut.txt");
      cout << "Removing the box from memory using the IOAble pointer..." << endl;
      delete Bp;
      bout.close();
   }
   else {
      cout << "Could not find the file \"boxes.txt\"." << endl;
   }
   cout << "Content of \"boxesOut.txt\" file" << endl;
   displayFile("boxesOut.txt");
}
/* Box *********************************************/
Box::Box() :m_hieght(0), m_width(0), csv(false) {
   cout << "defaulting Box" << endl;
};
ostream& Box::csvWrite(std::ostream& ostr)const {
   return ostr << m_hieght << "," << m_width;
}
istream& Box::csvRead(std::istream& istr) {
   istr >> m_hieght;
   istr.ignore();
   istr >> m_width;
   istr.ignore();
   return istr;
}
ostream& Box::write(ostream& ostr)const {
   if (csv) {
      csvWrite(ostr);
   }
   else {
      int i;
      for (int j = 0; j < m_hieght; j++) {
         for (i = 0; i < m_width * 2; i++, ostr << "*");
         ostr << endl;
      }
   }
   return ostr;
}
istream& Box::read(istream& istr) {
   if (csv) {
      csvRead(istr);
   }
   else {
      cout << "Height: ";
      istr >> m_hieght;
      cout << "Width: ";
      istr >> m_width;
   }
   return istr;
}
Box::~Box() {
   cout << "Box(" << m_hieght << "," << m_width << ") is gone!" << endl;
}
/* menuTester *********************************************/
void menuTester(Menu m) {
   cout << "Menu Tester **************************************" << endl;
   int selection;
   while (m >> selection) {
      switch (selection) {
      case 1:
         cout << "option one selected" << endl << endl;
         break;
      case 2:
         cout << "option two selected" << endl << endl;
         break;
      case 3:
         cout << "option three selected" << endl << endl;
         break;
      default:
         cout << "This will never happen!!!!" << endl;
         break;
      }
   }
   cout << "goodbye!" << endl;
}
/*  displayFile ***************************************/
void displayFile(const char* filename) {
   ifstream file(filename);
   cout << filename << "---------------------" << endl;
   char ch;
   while (file.get(ch) && cout << ch);
   cout << "---------------------------------" << endl;
}
OOP-Project-main/MS2/Time.cpp
#include "Time.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Time& Time::setToNow()
{
m_min = getTime();
return *this;
}
Time::Time(unsigned int min)
{
m_min = min;
}
std::ostream& Time::write(std::ostream &ostr) const
{
ostr.width(2);
ostr.fill('0');
ostr <<(m_min / 60);
ostr << ":";
ostr.width(2);
ostr.fill('0');
ostr << (m_min % 60);
return ostr;
}
std::istream& Time::read(std::istream &istr)
{
int _hour = 0;
int _min = 0;
char _delimiter;
istr >> _hour;
if (!istr) istr.setstate(ios::failbit);
else if (_hour < 0) istr.setstate(ios::failbit);
else {
istr >> _delimiter;
if (_delimiter != ':') istr.setstate(ios::failbit);
else {
istr >> _min;
if (_min < 0) istr.setstate(ios::failbit);
else m_min = (_hour * 60) + _min;
}
}
return istr;
}
Time& Time::operator-=(const Time &D)
{
if (this->m_min > D.m_min)
this->m_min -= D.m_min;
else
this->m_min = this->m_min + (1440 * ( (D.m_min / 1440) + 1)) - D.m_min;
return *this;
}
Time Time::operator-(const Time &D) const
{
Time temp;
if (this->m_min > D.m_min)
temp.m_min = this->m_min - D.m_min;
else
temp.m_min = this->m_min + (1440 * ((D.m_min / 1440) + 1)) - D.m_min;
return temp;
}
Time& Time::operator+=(const Time &D)
{
this->m_min += D.m_min;
return *this;
}
Time Time::operator+(const Time &D) const
{
Time temp;
temp.m_min = this->m_min + D.m_min;
return temp;
}
Time& Time::operator=(unsigned int val)
{
this->m_min = val;
return *this;
}
Time& Time::operator*=(unsigned int val)
{
this->m_min *= val;
return *this;
}
Time Time::operator*(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min * val;
return temp;
}
Time& Time::operator/=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operator/(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min / val;
return temp;
}
Time::operator int() const
{
return (int)m_min;
}
Time::operator unsigned int() const
{
return m_min;
}
std::ostream &operator<<(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operator>>(std::istream &istr, Time &D)
{
return D.read(istr);
}
}
OOP-Project-main/MS2/Time.h
#ifndef SDDS_TIMER_H
#define SDDS_TIMER_H
#include
namespace sdds {
class Time {
unsigned int m_min;
public:
Time& setToNow();
Time(unsigned int min = 0);
std::ostream& write(std::ostream& ostr) const;
std::istream& read(std::istream& istr);
Time& operator-=(const Time& D);
Time operator-(const Time& D)const;
Time& operator+=(const Time& D);
Time operator+(const Time& D)const;
Time& operator=(unsigned int val);
Time& operator *= (unsigned int val);
Time& operator /= (unsigned int val);
Time operator *(unsigned int val)const;
Time operator /(unsigned int val)const;
operator unsigned int()const;
operator int()const;
};
std::ostream& operator<<(std::ostream& ostr, const Time& D);
std::istream& operator>>(std::istream& istr, Time& D);
}
#endif // !SDDS_TIME_H
OOP-Project-main/MS2/utils.cpp
OOP-Project-main/MS2/utils.cpp
#define _CRT_SECURE_NO_WARNINGS
#include 
#include 
#include 
#include 
#include 
#include "utils.h"
#include "Time.h"
using namespace std;
namespace sdds {
   bool debug = false;  // made global in utils.h
   int getTime() {  
      int mins = -1;
      if (debug) {
         Time t(0);
         cout << "Enter current time: ";
         do {
            cin.clear();
            cin >> t;   // needs extraction operator overloaded for Time
            if (!cin) {
               cout << "Invlid time, try agian (HH:MM): ";
               cin.clear();
            }
            else {
               mins = int(t);
            }
            cin.ignore(1000, '\n');
         } while (mins < 0);
      }
      else {
         time_t t = time(NULL);
         tm lt = *localtime(&t);
         mins = lt.tm_hour * 60 + lt.tm_min;
      }
      return mins;
   }
   int getInt(const char *prompt)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  int getInt(int min, int max, const char *prompt,
             const char *errorMessage, bool showRangeAtError)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else if (_input < min || _input > max) {
          if (errorMessage) cout << errorMessage;
          if (showRangeAtError) cout << "[" << min << " <= value <= " << max << "]: ";
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  char *getcstr(const char *prompt, std::istream &istr, char delimiter)
  {
    char _input[BUFFER_SIZE];
    char *_outString;
    int _size = 0;
    int i     = 0;
    if (prompt) cout << prompt;
    istr.getline(_input, BUFFER_SIZE, delimiter);
    while (_input[_size] != '\0') _size++;
    _outString = new char[_size + 1];
    while (_input[i] != '\0') {
      _outString[i] = _input[i];
      i++;
    }
    _outString[i] = '\0';
    return _outString;
}
}
OOP-Project-main/MS2/utils.h
#ifndef SDDS_UTILS_H_
#define SDDS_UTILS_H_
#include
namespace sdds {
extern bool debug; // making sdds::debug variable global to all the files
// which include: "utils.h"
const int BUFFER_SIZE = 32767;
int getTime(); // returns the time of day in minutes
int getInt(const char *prompt = nullptr);

int getInt(int min, int max, const char *prompt = nullptr,
const char *errorMessage = nullptr, bool showRangeAtError = true);
char *getcstr(const char *prompt = nullptr, std::istream &istr = std::cin,
char delimiter = '\n');
}
#endif // !SDDS_UTILS_H_
OOP-Project-main/MS3/IOAble.cpp
#include "IOAble.h"
using namespace std;
namespace sdds
{
std::ostream &operator<<(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operator>>(std::istream &istr, IOAble &src)
{
return src.read(istr);
}
}
OOP-Project-main/MS3/IOAble.h
#ifndef SDDS_IOABLE_H
#define SDDS_IOABLE_H
#include
namespace sdds
{
class IOAble
{
public:
virtual std::ostream &csvWrite(std::ostream &ostr) const = 0;
virtual std::istream &csvRead(std::istream &istr) = 0;
virtual std::ostream &write(std::ostream &ostr) const = 0;
virtual std::istream &read(std::istream &istr) = 0;
virtual ~IOAble() {};
};
std::ostream &operator<<(std::ostream &ostr, const IOAble &src);
std::istream &operator>>(std::istream &istr, IOAble &src);
}
#endif
OOP-Project-main/MS3/ms3.csv
David Mason,111111111,10,12:50
Nick Gilmour,222222222,11,12:51
Roger Wright,333333333,12,12:52
Rick Waters,333333333,13,12:53
A name that is way way way way way way way way too long,444444444,14,12:54
OOP-Project-main/MS3/ms3.vcxproj



Debug
Win32


Release
Win32


Debug
x64


Release
x64



16.0
Win32Proj
{9d85c4f4-b4bf-4f39-b85b-6892b2a216df}
ms3
10.0



Application
true
v142
Unicode


Application
false
v142
true
Unicode


Application
true
v142
Unicode


Application
false
v142
true
Unicode




















true


false


true


false



Level3
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true




Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true




















OOP-Project-main/MS3/ms3.vcxproj.filters



{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx


{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd


{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms




Source Files


Source Files


Source Files


Source Files


Source Files


Source Files




Header Files


Header Files


Header Files


Header Files


Header Files


OOP-Project-main/MS3/ms3out.csv
W,David Mason,111111111,10,12:50
W,Nick Gilmour,222222222,11,12:51
W,Roger Wright,333333333,12,12:52
W,Rick Waters,333333333,13,12:53
W,A name that is way way way way way way way way too long,444444444,14,12:54
OOP-Project-main/MS3/ms3Tester.cpp
OOP-Project-main/MS3/ms3Tester.cpp
// Patient Tester:
// Version: 1.0
// Date: 2021-06-23
// Author: Fardad
// Description:
// This file tests the Patient Module of your project
/////////////////////////////////////////////
#include 
#include 
using namespace std;
#include "utils.h"
#include "Patient.h"
namespace sdds {
   class WalkinPatient : public Patient {
   public:
     WalkinPatient(int ticketNumber = 0, bool fileIO = false):
        Patient(ticketNumber,fileIO){ }
     char type()const {
        return 'W';
     }
     std::ostream& write(std::ostream& ostr)const {
        return fileIO() ? csvWrite(ostr) : Patient::write(ostr);
     }
     std::istream& read(std::istream& istr) {
        return fileIO() ? csvRead(istr).ignore(1000,'\n') : Patient::read(istr);
     }
   };
}
using namespace sdds;
void displayFile(const char* filename) {
   ifstream file(filename);
   cout << filename << "-----------------------" << endl;
   char ch;
   while (file.get(ch) && cout << ch);
   cout << "---------------------------------" << endl;
}
void testOperatorsCastAndNumber(const Patient& A, const Patient& B);
int main() {
   sdds::debug = true;
   ifstream csvfile("ms3.csv");
   ofstream csvoutfile("ms3out.csv");
   Patient* p = new WalkinPatient(24);
   WalkinPatient W;
   cout << "Enter The following:" << endl <<
      "-------------------\nJohn Doe\nabc\n"
      "100\n123123123\n12:34\n-------------------" << endl;
   cin >> *p;
   p->setArrivalTime();
   cout << "Sections 1 and 2 should match: " << endl << endl;
   cout << "1- Your output on screen:" << endl << *p << endl;
   cout << "2- The output should be :" << endl <<
      "Ticket No: 24, Issued at: 12:34\n"
      "John Doe, OHIP: 123123123" << endl << endl;
   p->fileIO(true);
   cout << "1- Your comma separated ouput: " << endl << *p << endl;
   cout << "2- comma separated ouput should be: " << endl <<
      "W,John Doe,123123123,24,12:34" << endl << endl;
   cout << "Enter the following: " << endl;
   cout << ">Jo Lee,234234234,200,12:50" << endl << ">";
   p->fileIO(true);
   cin >> *p;
   cout << "Sections 1 and 2 should match: " << endl << endl;
   p->fileIO(false);
   cout << "1- Your output on screen:" << endl;
   cout << *p << endl;
   cout << "2- The output should be:" << endl;
   cout << "Ticket No: 200, Issued at: 12:50\n"
           "Jo Lee, OHIP: 234234234" << endl<   cout << "Testing File IO: " << endl;
   int i = 0;
   W.fileIO(true);
   while (csvfile) {
      csvfile >> W;
      if (csvfile) {
         W.fileIO(false);
         cout << ++i << " -----------------------------------------------" << endl
 << W << endl << endl;
         W.fileIO(true);
         csvoutfile << W << endl;
      }
   }
   csvoutfile.close();
   displayFile("ms3out.csv");
   W.fileIO(false);
   p->fileIO(false);
   testOperatorsCastAndNumber(W, *p);
   delete p;
   return 0;
}
void testOperatorsCastAndNumber(const Patient& A, const Patient& B) {
   cout << "Testing operator== overloads: " << endl;
   cout << (A == 'W' ? "Success!" : "Failed!") << endl;
   cout << (A == B ? "Success!" : "Failed!") << endl;
   cout << "Testing Time cast and number: " << endl;
   cout << "Sections 1 and 2 should match: " << endl << endl;
   cout << "1- Your output on screen:" << endl;
   cout << "W, Ticket Time: " << Time(A) << endl;
   cout << "W, Ticket number: " << A.number() << endl;
   cout << "2- The output should be:" << endl;
   cout << "W, Ticket Time: 12:54" << endl <<
      "W, Ticket number : 14" << endl;
}
OOP-Project-main/MS3/Patient.cpp
#include
#include
#include "Patient.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Patient::Patient(int ticketNumber, bool fileIO) {
m_ticket = ticketNumber;
m_IOFlag = fileIO;
}
Patient::~Patient() {
if (m_NameOfPatient) {
delete[] m_NameOfPatient;
m_NameOfPatient = nullptr;
}
}
const bool Patient::fileIO() const {
return m_IOFlag;
}
void Patient::fileIO(bool _reset) {
m_IOFlag = _reset;
}
bool Patient::operator==(const char _singleChar) const {
return this->type() == _singleChar;
}
bool Patient::operator==(const Patient &src) const {
return this->type() == src.type();
}
void Patient::setArrivalTime() {
m_ticket.resetTime();
}
Patient::operator Time() const {
return Time(m_ticket);
}
int Patient::number() const {
return m_ticket.number();
}
std::ostream& Patient::csvWrite(std::ostream &ostr) const {
ostr << this->type() << ',' << m_NameOfPatient << ',' << m_NumOfOHIP << ',';
m_ticket.csvWrite(ostr);
return ostr;
}
std::istream& Patient::csvRead(std::istream &istr) {
string temp;
char _comma;
getline(istr, temp, ',');
if (m_NameOfPatient) {
delete[] m_NameOfPatient;
m_NameOfPatient = nullptr;
}
m_NameOfPatient = new char[strlen(temp.c_str()) + 1];
strcpy(m_NameOfPatient, temp.c_str());
istr >> m_NumOfOHIP >> _comma;
m_ticket.csvRead(istr);
return istr;
}
std::ostream& Patient::write(std::ostream &ostr) const {
ostr << "Ticket No: " << m_ticket.number() << ", Issued at: " << Time(*this) << endl;
if (strlen(m_NameOfPatient) > 25) {
for (int i = 0; i < 25; i++)
ostr << m_NameOfPatient[i];
}
else ostr << m_NameOfPatient;
ostr << ", OHIP: " << m_NumOfOHIP;
return ostr;
}
std::istream& Patient::read(std::istream &istr) {
char *temp = getcstr("Name: ", istr);
if (m_NameOfPatient) {
delete[] m_NameOfPatient;
m_NameOfPatient = nullptr;
}
m_NameOfPatient = new char[strlen(temp) + 1];
strcpy(m_NameOfPatient, temp);
delete[] temp;
m_NumOfOHIP = getInt(100000000, 999999999, "OHIP:", "Invalid OHIP Number, ");
return istr;
}
}
OOP-Project-main/MS3/Patient.h
#ifndef SDDS_PATIENT_H_
#define SDDS_PATIENT_H_
#include "IOAble.h"
#include "Ticket.h"
// #include "Time.h"
namespace sdds
{
class Patient : public IOAble
{
char *m_NameOfPatient {nullptr};
int m_NumOfOHIP {0};
Ticket m_ticket{0};
bool m_IOFlag;
public:
Patient(int ticketNumber = 0, bool fileIO = false);
~Patient();
Patient(const Patient &) = delete;
Patient &operator=(const Patient &) = delete;
virtual char type() const = 0;
const bool fileIO() const;
void fileIO(bool _reset);
bool operator==(const char _singleChar) const;
bool operator==(const Patient &src) const;
void setArrivalTime();
operator Time() const;
int number() const;
std::ostream &csvWrite(std::ostream &ostr) const;
std::istream &csvRead(std::istream &istr);
std::ostream &write(std::ostream &ostr) const;
std::istream &read(std::istream &istr);
};
}
#endif
OOP-Project-main/MS3/Ticket.cpp
#include "Ticket.h"
namespace sdds {
Ticket::Ticket(int number) {
m_number = number;
}
Ticket::operator Time() const {
return m_time;
}
int Ticket::number() const {
return m_number;
}
void Ticket::resetTime() {
m_time.setToNow();
}
std::ostream& Ticket::csvWrite(std::ostream& ostr) const {
return ostr << m_number << "," << m_time;
}
std::istream& Ticket::csvRead(std::istream& istr) {
istr >> m_number;
istr.ignore();
return istr >> m_time;
}
std::ostream& Ticket::write(std::ostream& ostr) const {
return ostr << "Ticket No: " << m_number << ", Issued at: " << m_time ;
}
std::istream& Ticket::read(std::istream& istr) {
return csvRead(istr);
}
}
OOP-Project-main/MS3/Ticket.h
#ifndef SDDS_TICKET_H_
#define SDDS_TICKET_H_
#include "Time.h"
#include "IOAble.h"
namespace sdds {
class Ticket:public IOAble{
Time m_time;
int m_number;
public:
Ticket(int number);
operator Time()const;
int number()const;
void resetTime();
std::ostream& csvWrite(std::ostream& ostr)const;
std::istream& csvRead(std::istream& istr);
std::ostream& write(std::ostream& ostr )const;
std::istream& read(std::istream& istr);
};
}
#endif // !SDDS_TICKET_H_
OOP-Project-main/MS3/Time.cpp
#include "Time.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Time& Time::setToNow()
{
m_min = getTime();
return *this;
}
Time::Time(unsigned int min)
{
m_min = min;
}
std::ostream& Time::write(std::ostream &ostr) const
{
ostr.width(2);
ostr.fill('0');
ostr <<(m_min / 60);
ostr << ":";
ostr.width(2);
ostr.fill('0');
ostr << (m_min % 60);
return ostr;
}
std::istream& Time::read(std::istream &istr)
{
int _hour = 0;
int _min = 0;
char _delimiter;
istr >> _hour;
if (!istr) istr.setstate(ios::failbit);
else if (_hour < 0) istr.setstate(ios::failbit);
else {
istr >> _delimiter;
if (_delimiter != ':') istr.setstate(ios::failbit);
else {
istr >> _min;
if (_min < 0) istr.setstate(ios::failbit);
else m_min = (_hour * 60) + _min;
}
}
return istr;
}
Time& Time::operator-=(const Time &D)
{
if (this->m_min > D.m_min)
this->m_min -= D.m_min;
else
this->m_min = this->m_min + (1440 * ( (D.m_min / 1440) + 1)) - D.m_min;
return *this;
}
Time Time::operator-(const Time &D) const
{
Time temp;
if (this->m_min > D.m_min)
temp.m_min = this->m_min - D.m_min;
else
temp.m_min = this->m_min + (1440 * ((D.m_min / 1440) + 1)) - D.m_min;
return temp;
}
Time& Time::operator+=(const Time &D)
{
this->m_min += D.m_min;
return *this;
}
Time Time::operator+(const Time &D) const
{
Time temp;
temp.m_min = this->m_min + D.m_min;
return temp;
}
Time& Time::operator=(unsigned int val)
{
this->m_min = val;
return *this;
}
Time& Time::operator*=(unsigned int val)
{
this->m_min *= val;
return *this;
}
Time Time::operator*(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min * val;
return temp;
}
Time& Time::operator/=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operator/(unsigned int val) const
{
Time temp;
temp.m_min = this->m_min / val;
return temp;
}
Time::operator int() const
{
return (int)m_min;
}
Time::operator unsigned int() const
{
return m_min;
}
std::ostream &operator<<(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operator>>(std::istream &istr, Time &D)
{
return D.read(istr);
}
}
OOP-Project-main/MS3/Time.h
#ifndef SDDS_TIMER_H
#define SDDS_TIMER_H
#include
namespace sdds {
class Time {
unsigned int m_min;
public:
Time& setToNow();
Time(unsigned int min = 0);
std::ostream& write(std::ostream& ostr) const;
std::istream& read(std::istream& istr);
Time& operator-=(const Time& D);
Time operator-(const Time& D)const;
Time& operator+=(const Time& D);
Time operator+(const Time& D)const;
Time& operator=(unsigned int val);
Time& operator *= (unsigned int val);
Time& operator /= (unsigned int val);
Time operator *(unsigned int val)const;
Time operator /(unsigned int val)const;
operator unsigned int()const;
operator int()const;
};
std::ostream& operator<<(std::ostream& ostr, const Time& D);
std::istream& operator>>(std::istream& istr, Time& D);
}
#endif // !SDDS_TIME_H
OOP-Project-main/MS3/utils.cpp
OOP-Project-main/MS3/utils.cpp
#define _CRT_SECURE_NO_WARNINGS
#include 
#include 
#include 
#include 
#include 
#include "utils.h"
#include "Time.h"
using namespace std;
namespace sdds {
   bool debug = false;  // made global in utils.h
   int getTime() {  
      int mins = -1;
      if (debug) {
         Time t(0);
         cout << "Enter current time: ";
         do {
            cin.clear();
            cin >> t;   // needs extraction operator overloaded for Time
            if (!cin) {
               cout << "Invlid time, try agian (HH:MM): ";
               cin.clear();
            }
            else {
               mins = int(t);
            }
            cin.ignore(1000, '\n');
         } while (mins < 0);
      }
      else {
         time_t t = time(NULL);
         tm lt = *localtime(&t);
         mins = lt.tm_hour * 60 + lt.tm_min;
      }
      return mins;
   }
   int getInt(const char *prompt)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  int getInt(int min, int max, const char *prompt,
             const char *errorMessage, bool showRangeAtError)
  {
    int _input;
    char _buffer;
    bool _flag = false;
    if (prompt) cout << prompt;
    do {
      cin >> _input;
      if (!cin) {
        cout << "Bad integer value, try again: ";
        cin.clear();
        cin.ignore(BUFFER_SIZE, '\n');
      }
      else {
        cin.get(_buffer);
        if (_buffer != '\n') {
          cout << "Enter only an integer, try again: ";
          cin.clear();
          cin.ignore(BUFFER_SIZE, '\n');
        }
        else if (_input < min || _input > max) {
          if (errorMessage) cout << errorMessage;
          if (showRangeAtError) cout << "[" << min << " <= value <= " << max << "]: ";
        }
        else _flag = true;
      }
    } while (!_flag);
    return _input;
  }
  char *getcstr(const char *prompt, std::istream &istr, char delimiter)
  {
    char _input[BUFFER_SIZE];
    char *_outString;
    int _size = 0;
    int i     = 0;
    if (prompt) cout << prompt;
    istr.getline(_input, BUFFER_SIZE, delimiter);
    while (_input[_size] != '\0') _size++;
    _outString = new char[_size + 1];
    while (_input[i] != '\0') {
      _outString[i] = _input[i];
      i++;
    }
    _outString[i] = '\0';
    return _outString;
}
}
OOP-Project-main/MS3/utils.h
#ifndef SDDS_UTILS_H_
#define SDDS_UTILS_H_
#include
namespace sdds {
extern bool debug; // making sdds::debug variable global to all the files
// which include: "utils.h"
const int BUFFER_SIZE = 32767;
int getTime(); // returns the time of day in minutes
int getInt(const char *prompt = nullptr);

int getInt(int min, int max, const char *prompt = nullptr,
const char *errorMessage = nullptr, bool showRangeAtError = true);
char *getcstr(const char *prompt = nullptr, std::istream &istr = std::cin,
char delimiter = '\n');
}
#endif // !SDDS_UTILS_H_
OOP-Project-main/MS4/CovidPatient.cpp
#include "CovidPatient.h"
using namespace std;
namespace sdds {
int nextCovidTicket = 1;
CovidPatient::CovidPatient() : Patient(nextCovidTicket) {
nextCovidTicket++;
}
char CovidPatient::type() const {
return 'C';
}
std::istream &CovidPatient::csvRead(std::istream &istr) {
Patient::csvRead(istr);
nextCovidTicket = Patient::number() + 1;
istr.ignore();
return istr;
}
std::ostream &CovidPatient::write(std::ostream &ostr) const {
if (Patient::fileIO()) Patient::csvWrite(ostr);
else {
ostr << "COVID TEST" << endl;
Patient::write(ostr) << endl;
}
return ostr;
}
std::istream &CovidPatient::read(std::istream &istr) {
Patient::fileIO() == true ? csvRead(istr) : Patient::read(istr);
return istr;
}
}
OOP-Project-main/MS4/CovidPatient.h
#ifndef SDDS_COVIDPATIENT_H_
#define SDDS_COVIDPATIENT_H_
#include "Patient.h"
namespace sdds {
class CovidPatient : public Patient
{
public:
CovidPatient();
// ======== pure virtual function overwrites ========
char type() const;
std::istream &csvRead(std::istream &istr);
std::ostream &write(std::ostream &ostr) const;
std::istream &read(std::istream &istr);
};
}
#endif // !SDDS_COVIDPATIENT_H_
OOP-Project-main/MS4/images/classes.png
OOP-Project-main/MS4/images/time.png
OOP-Project-main/MS4/IOAble.cpp
#include "IOAble.h"
using namespace std;
namespace sdds
{
std::ostream &operator<<(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operator>>(std::istream &istr, IOAble &src)
{
return src.read(istr);
}
}
OOP-Project-main/MS4/IOAble.h
#ifndef SDDS_IOABLE_H
#define SDDS_IOABLE_H
#include
namespace sdds
{
class IOAble
{
public:
virtual std::ostream &csvWrite(std::ostream &ostr) const = 0;
virtual std::istream &csvRead(std::istream &istr) = 0;
virtual std::ostream &write(std::ostream &ostr) const = 0;
virtual std::istream &read(std::istream &istr) = 0;
virtual ~IOAble() {};
};
std::ostream &operator<<(std::ostream &ostr, const IOAble &src);
std::istream &operator>>(std::istream &istr, IOAble &src);
}
#endif
OOP-Project-main/MS4/ms4.vcxproj



Debug
Win32


Release
Win32


Debug
x64


Release
x64



16.0
Win32Proj
{557ae064-b8c7-4158-a43b-6aa2cbb729b0}
ms4
10.0



Application
true
v142
Unicode


Application
false
v142
true
Unicode


Application
true
v142
Unicode


Application
false
v142
true
Unicode




















true


false


true


false



Level3
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true




Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true




Level3
true
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true


Console
true
true
true



























OOP-Project-main/MS4/ms4.vcxproj.filters



{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx


{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd


{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms




Source Files


Source Files


Source Files


Source Files


Source Files


Source Files


Source Files


Source Files




Header Files


Header Files


Header Files


Header Files


Header Files


Header Files


Header Files




Resource Files


OOP-Project-main/MS4/ms4Tester.cpp
OOP-Project-main/MS4/ms4Tester.cpp
// MS4 Tester
// file: ms4Tester.cpp
// Version: 1.0
// Date: 2021-06-23
// Author: Fardad
// Description:
// This file tests the CovidPatient and TriagePatient
// Modules of your project
/////////////////////////////////////////////
#include 
using namespace std;
#include "Patient.h"
#include "CovidPatient.h"
#include "TriagePatient.h"
#include "utils.h"
using namespace sdds;
void CPTest();
void TPTest();
int main() {
   cout << "Milestone 4 tester" << endl;
   CPTest();
   TPTest();
   return 0;
}
void CPTest() {
   sdds::debug = true;
   CovidPatient A, B;
   cout << "Testing CovidPatient:" << endl
<< "Enter the following:" << endl
<< "Enter current time: 12:34" << endl
<< "Name: aaa" << endl
<< "OHIP: 111111111" << endl;
   A.setArrivalTime();
   cout << "Enter Patient information:" << endl;
   A.fileIO(false);
   cin >> A;
   cout << "Enter the following:" << endl
<< "Enter current time: 12:35" << endl
<< "Name: bbb" << endl
<< "OHIP: 222222222" << endl;
   B.setArrivalTime();
   cout << "Enter Patient information:" << endl;
   B.fileIO(false);
   cin >> B;
   cout << endl << "Patients information entered:" << endl;
   cout << A << endl << B << endl;
   A.fileIO(true);
   B.fileIO(true);
   cout << "CSV output: " << endl;
   cout << A << endl << B << endl << endl;
   cout << "Testing CSV input:" << endl
<< "Enter the following:" << endl;
   cout << ">ccc,333333333,10,23:45" << endl << ">";
   cin >> A;
   cout << endl << "Data entered:" << endl;
   A.fileIO(false);
   cout << A << endl;
   cout << "Testing global ticket number variable:" << endl
<< "Enter the following: " << endl
<< "Enter current time: 23:55" << endl
<< "Name: ddd" << endl
<< "OHIP: 444444444" << endl;
   CovidPatient C;
   C.setArrivalTime();
   C.fileIO(false);
   cin >> C;
   cout << "Patient information entered:" << endl;
   cout << C << endl;
}
void TPTest() {
   sdds::debug = true;
   TriagePatient A, B;
   cout << "Testing TriagePatient:" << endl
<< "Enter the following:" << endl
<< "Enter current time: 12:34" << endl
<< "Name: aaa" << endl
<< "OHIP: 111111111" << endl
<< "Symptoms: aaa aaa aaa" << endl;
   A.setArrivalTime();
   cout << "Enter Patient information:" << endl;
   A.fileIO(false);
   cin >> A;
   cout << "Enter the following:" << endl
<< "Enter current time: 12:35" << endl
<< "Name: bbb" << endl
<< "OHIP: 222222222" << endl
<< "Symptoms: bbb bbb bbb" << endl;
   B.setArrivalTime();
   cout << "Enter Patient information:" << endl;
   B.fileIO(false);
   cin >> B;
   cout << endl << "Patients information entered:" << endl;
   cout << A << endl << B << endl;
   A.fileIO(true);
   B.fileIO(true);
   cout << "CSV output: " << endl;
   cout << A << endl << B << endl << endl;
   cout << "Testing CSV input:" << endl
<< "Enter the following:" << endl;
   cout << ">ccc,333333333,10,23:45,ccc ccc ccc" << endl << ">";
   cin >> A;
   cout << endl << "Data entered:" << endl;
   A.fileIO(false);
   cout << A << endl;
   cout << "Testing global ticket number variable and DMA:" << endl
<< "Enter the following: " << endl
<< "Enter current time: 23:55" << endl
<< "Name: ddd" << endl
<< "OHIP: 444444444" << endl
<< "Copy and paste the follwoing for Symptoms:" << endl <<
      "Socks"
      " Box"
      " Knox"
      " Know in box."
      " Fox in socks."
      " Knox on fox"
      " In socks in box."
      " Socks on Knox"
      " And Knox in box."
      " Fox in socks"
      " On box on Knox."
      " Chicks with bricks come."
      " Chicks with blocks come."
      " Chicks with Bricks and"
      " Blocks and clocks come."
      " Look, sir.Look, sir."
      " Mr Knox, sir."
      " Let's do tricks with"
      " Bricks and blocks, sir."
      " Let's do tricks with"
      " Chicks and clocks, sir."
      " First, I'll make a"
      " Quick trick brick stack."
      " Then I'll make a"
      " Quick trick block stack." << endl;
   TriagePatient C;
   C.setArrivalTime();
   C.fileIO(false);
   cin >> C;
   cout << "Patient information entered:" << endl;
   cout << C << endl;
}
OOP-Project-main/MS4/Patient.cpp
#include
#include
#include "Patient.h"
#include "utils.h"
using namespace std;
namespace sdds
{
Patient::Patient(int ticketNumber, bool fileIO) {
m_ticket = ticketNumber;
m_IOFlag = fileIO;
}
Patient::~Patient() {
if (m_NameOfPatient) {
delete[] m_NameOfPatient;
m_NameOfPatient = nullptr;
}
}
const bool Patient::fileIO() const {
return m_IOFlag;
}
void Patient::fileIO(bool _reset) {
m_IOFlag = _reset;
}
bool Patient::operator==(const char _singleChar) const {
return this->type() == _singleChar;
}
bool Patient::operator==(const Patient &src) const {
return this->type() == src.type();
}
void Patient::setArrivalTime() {
m_ticket.resetTime();
}
Patient::operator Time() const {
return Time(m_ticket);
}
int Patient::number() const {
return m_ticket.number();
}
std::ostream& Patient::csvWrite(std::ostream &ostr) const {
ostr << this->type() << ',' << m_NameOfPatient << ',' << m_NumOfOHIP << ',';
m_ticket.csvWrite(ostr);
return ostr;
}
std::istream& Patient::csvRead(std::istream &istr) {
string temp;
char _comma;
getline(istr, temp, ',');
if (m_NameOfPatient) {
delete[] m_NameOfPatient;
m_NameOfPatient = nullptr;
}
m_NameOfPatient = new char[strlen(temp.c_str()) + 1];
strcpy(m_NameOfPatient, temp.c_str());
istr >> m_NumOfOHIP >> _comma;
m_ticket.csvRead(istr);
return istr;
}
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here