Solution
Pulkit answered on
Aug 13 2021
OOP-Project-main/.gitignore
# Visual Studio
*.sdf
*.sln
*.use
*.suo
*.opensdf
*.d
Debug
ipch
x64
.vs
#tempfiles
~$_*.*
#codelite
.clang
.codelite
Debug
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic li
aries
*.so
*.dyli
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static li
aries
*.lai
*.la
*.a
*.li
# 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;mfcri
on-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:
ENTER>"Â
 endl;
   coutÂ
 "12,12"Â
 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Â
others 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::operato
=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operato
(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 &operato
(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operato
(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& operato
(std::ostream& ostr, const Time& D);
std::istream& operato
(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 cu
ent 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 *e
orMessage, bool showRangeAtE
or)
  {
    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 (e
orMessage)Â coutÂ
 e
orMessage;
          if (showRangeAtE
or)Â 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 *e
orMessage = nullptr, bool showRangeAtE
or = true);
char *getcstr(const char *prompt = nullptr, std::istream &istr = std::cin,
char delimiter = '\n');
}
#endif
!SDDS_UTILS_H_
OOP-Project-main/MS2
oxes.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 &operato
(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operato
(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 &operato
(std::ostream &ostr, const IOAble &src);
std::istream &operato
(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::operato
(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 &operato
(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;mfcri
on-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;
        Â
eak;
      case 2:
         coutÂ
 "option two selected"Â
 endlÂ
 endl;
        Â
eak;
      case 3:
         coutÂ
 "option three selected"Â
 endlÂ
 endl;
        Â
eak;
      default:
         coutÂ
 "This will never happen!!!!"Â
 endl;
        Â
eak;
      }
   }
   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::operato
=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operato
(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 &operato
(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operato
(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& operato
(std::ostream& ostr, const Time& D);
std::istream& operato
(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 cu
ent 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 *e
orMessage, bool showRangeAtE
or)
  {
    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 (e
orMessage)Â coutÂ
 e
orMessage;
          if (showRangeAtE
or)Â 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 *e
orMessage = nullptr, bool showRangeAtE
or = 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 &operato
(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operato
(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 &operato
(std::ostream &ostr, const IOAble &src);
std::istream &operato
(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;mfcri
on-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->setA
ivalTime();
   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
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::setA
ivalTime() {
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 setA
ivalTime();
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::operato
=(unsigned int val)
{
this->m_min /= val;
return *this;
}
Time Time::operato
(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 &operato
(std::ostream &ostr, const Time &D)
{
return D.write(ostr);
}
std::istream &operato
(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& operato
(std::ostream& ostr, const Time& D);
std::istream& operato
(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 cu
ent 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 *e
orMessage, bool showRangeAtE
or)
  {
    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 (e
orMessage)Â coutÂ
 e
orMessage;
          if (showRangeAtE
or)Â 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 *e
orMessage = nullptr, bool showRangeAtE
or = 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 &operato
(std::ostream &ostr, const IOAble &src)
{
return src.write(ostr);
}
std::istream &operato
(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 &operato
(std::ostream &ostr, const IOAble &src);
std::istream &operato
(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-6aa2c
729b0}
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;mfcri
on-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 Teste
 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 cu
ent time: 12:34"Â
 endl
     Â
 "Name: aaa"Â
 endl
     Â
 "OHIP: 111111111"Â
 endl;
   A.setA
ivalTime();
   coutÂ
 "Enter Patient information:"Â
 endl;
   A.fileIO(false);
   cinÂ
 A;
   coutÂ
 "Enter the following:"Â
 endl
     Â
 "Enter cu
ent time: 12:35"Â
 endl
     Â
 "Name:Â
"Â
 endl
     Â
 "OHIP: 222222222"Â
 endl;
   B.setA
ivalTime();
   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 cu
ent time: 23:55"Â
 endl
     Â
 "Name: ddd"Â
 endl
     Â
 "OHIP: 444444444"Â
 endl;
   CovidPatient C;
   C.setA
ivalTime();
   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 cu
ent time: 12:34"Â
 endl
     Â
 "Name: aaa"Â
 endl
     Â
 "OHIP: 111111111"Â
 endl
     Â
 "Symptoms: aaa aaa aaa"Â
 endl;
   A.setA
ivalTime();
   coutÂ
 "Enter Patient information:"Â
 endl;
   A.fileIO(false);
   cinÂ
 A;
   coutÂ
 "Enter the following:"Â
 endl
     Â
 "Enter cu
ent time: 12:35"Â
 endl
     Â
 "Name:Â
"Â
 endl
     Â
 "OHIP: 222222222"Â
 endl
     Â
 "Symptoms:Â
Â
Â
"Â
 endl;
   B.setA
ivalTime();
   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 cu
ent 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Â
icks 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Â
ick stack."
      " Then I'll make a"
      " Quick trick block stack."Â
 endl;
   TriagePatient C;
   C.setA
ivalTime();
   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::setA
ivalTime() {
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;
}
...