


#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "MyString.h"



MyString::MyString()
{
           array[0]='\0';
           length=0;
}




MyString::MyString(const char* s)
{
   if(sizeof(s) > 81)
   {
                for(int i = 0; i<81; i++)
                {
                        array[i] = s[i];
                }
                array[81] = '\0';
   }
   else
   {
       strcpy(array, s);
   }
   if(strlen(s) < 81)
   {
                length = strlen(s);
   }
   else
   {
       length=81;
   }
}      


bool MyString::operator==(const MyString& rightOp) const
{

  if(strcmp(array,rightOp.array)==0)
        {
                return true;
        }
        else
        {
                return false;
        }     
}






bool MyString::operator==(const char* rightOp) const
{
         if(strcmp(array, rightOp)==0)
        {
                return true;
        }
        else
        {
                return false;
        }
}





char& MyString::operator[](int sub)
{
      return array[sub];
}



char MyString::operator[](int sub) const
{
     return array[sub];
     
}





const char* MyString::c_str() const
{
      return array;
}






int MyString::size() const
{
    return length;
}





bool MyString::empty() const
{
     if(length== '0')
       {
        return true;
       }  

     else
        { 
        return false;
         }  
}




void MyString::clear()
{
      array[0]='\0';
      length=0;
}




ostream& operator<<(ostream& leftOp, const MyString& rightOp)
{
         leftOp<<rightOp.array;
         return leftOp;
}





istream& operator>> (istream& leftOp, MyString& rightOp)
{
         leftOp>>rightOp.array;
         rightOp.length=strlen(rightOp.array);
         return leftOp;
}
       
bool operator==(const char* leftOp, const MyString& rightOp)
{
     if(strcmp(leftOp, rightOp.array)==0)
     {
        return true;
     }
     else
     {
        return false;
     }  
     
     
}  
