#include <iostream>
#include<fstream>
#include<string.h>
#include<iomanip>
#include<cctype>
#include "FarmSoftware.h"



const int MaxSize=1000;  // Specify a limit for Container size which user is not
                         // permitted to go beyond.


FarmAnimal::FarmAnimal() {}

FarmAnimal::~FarmAnimal() {}



void FarmAnimal::setAnimalid(bool setby, string id)    // These Accessor default value functions can provide
{                                                      // generic data to structure for testing and debugging
                                                       // and will also screen the data for integrity and
                                                       // correct format before passing it to object variable.
bool Valid=false;
    if (setby==true)
    {
        cout<<"enter a 12 digit animal id please\n";


getline(cin,id);
        Valid=CheckIfAnimalIdIsValid(id);                // Seperate functions for data integrity and format checking.
        if(Valid==false){

            cout<<"Invalid data or incorrect length,try again\n";
            setAnimalid(true);
                        }
       else if(Valid==true){
        Animalid=id;
                           }
    }
else if(setby==false) {
Animalid=id;

                      }
}


void FarmAnimal::setInWeight(bool setby,int theInWeight)
{

    if (setby==true)
    {

        cout<<"Please enter the initial weight of the Animal in kgs\n";

        while (!(cin >>theInWeight))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again\n ";
  }
cin.ignore(80, '\n');

        InWeight=theInWeight;
    }
    else if(setby==false)
    {
        InWeight=theInWeight;

    }
}

void FarmAnimal::setOutWeight(bool setby,int theOutWeight)
{

    if (setby==true)
    {

        cout<<"Please enter the sell weight of the Animal in kgs\n";

        while (!(cin>>theOutWeight))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again \n";
  }
cin.ignore(80, '\n');
        OutWeight=theOutWeight;
    }
    else if(setby==false)
    {
        OutWeight=theOutWeight;

    }
}

void FarmAnimal::setCost(bool setby,int cost)
{

    if (setby==true)
    {
        cout<<"please enter the cost of the animal\n";


  while (!(cin>>cost))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number:try again\n ";
  }
  cin.ignore(80, '\n');



        Cost=cost;
    }
    else if (setby==false)
    {

        Cost=cost;
    }
}

void FarmAnimal::setAvCostProcess(bool setby,int theAvCostProcess)
{

    if (setby==true)
    {

        cout<<"Please enter the average cost incurred for the Animal\n";

        while (!(cin>>theAvCostProcess))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again\n";
  }

        AvCostProcess=theAvCostProcess;
    }
    else if(setby==false)
    {
        AvCostProcess=theAvCostProcess;
    }
}

void FarmAnimal::setSex(bool setby,string theSex)
{

int len=0;

    if (setby==true)
    {

        cout<<"Please enter the sex of the Animal in the format m or f\n";


        getline(cin,theSex);
        len=theSex.length();




        if((len==1)&&((theSex[0]=='m')||(theSex[0]=='f'))){
            Sex=theSex;
                                                          }
         else{
                cout<<"invalid data. Try again\n";      //Integrity of string data must also be ensured.

                setSex(true);                           //Use recursion to force user to enter valid data.

             }

    }

    else if(setby==false)
    {

        Sex=theSex;
    }
}


int FarmAnimal::setBreed(bool setby,string theBreed)
{
bool Valid=false;

    if (setby==true)
    {

        cout<<"please enter the breed of this animal\n";
        cout<<"\n";

        getline(cin,theBreed);

        Valid=CheckIfStringIsValid(theBreed);    //Let a data integrity checking function handle this.
        if (Valid==true){
            Breed=theBreed;
            return 0;
                         }
        else if(Valid==false){

            cout<<"Invalid input,please try again\n";
            setBreed(true);                                //Use recursion to force user to enter valid data.
                             }

    }

   else if(setby==false)
    {

        Breed=theBreed;
    }
return 0;
}

int FarmAnimal::setSupplierName(bool setby,string suppname)
{
bool Valid=false;

    if(setby==true)
    {

        cout<<"please enter the name of the person who supplied this animal\n";
        cout<<"\n";

        getline(cin,suppname);

        Valid=CheckIfStringIsValid(suppname);
        if (Valid==true){
            SupplierName=suppname;
            return 0;
                        }
        else if(Valid==false){

            cout<<"Invalid input,please try again\n";
            setSupplierName(true);
                             }

    }
    else if (setby==false)
    {
        SupplierName=suppname;
    }
return 0;
}

void FarmAnimal::setBoughtDate(bool setby,string BDate)
{


bool Valid=false;
    if(setby==true)
    {


        cout<<"Please enter the date the animal was bought in the form ##/##/##\n";

        getline(cin,BDate);
        Valid=CheckIfDateIsValid(BDate);

       if (Valid==true){
        BoughtDate=BDate;

                       }
        else if(Valid==false) {
            cout<<"The Data you entered is either invalid data or is in the incorrect format. Try again\n";
            setBoughtDate(true);

                              }
    }
    else if (setby==false)
    {

        BoughtDate=BDate;
    }


}

void FarmAnimal::setRetailPricePerkg(bool setby,float theRetailPricePerkg)
{
float TheGrossSalePrice;
int   OutWeight;
    if (setby==true)
    {
        cout<<"Please enter the retail price/kilo acquired for the sale of the Animal\n";

        while (!(cin>>theRetailPricePerkg))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again \n";
  }
        RetailPricePerkg=theRetailPricePerkg;                //Both the retail price/kg and the kill/outweight will
        OutWeight=getOutWeight();                            //dictate the gross sale price so why not calculate it
        TheGrossSalePrice=(OutWeight*theRetailPricePerkg);   //here and pass it to the setGrossSalePrice function.
        setGrossSaleprice(false,TheGrossSalePrice);
        setSoldFlag(1);

    }
    else if(setby==false)
    {
        RetailPricePerkg=theRetailPricePerkg;
    }
}


void FarmAnimal::setGrossSaleprice(bool setby,float Grosssaleprice)
{

    if (setby==true)
    {
        cout<<"please enter a saleprice for the animal\n";

        while (!(cin >> Grosssaleprice))
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again\n";
  }
cin.ignore(80, '\n');
        GrossSaleprice=Grosssaleprice;

    }
    else if (setby==false)
    {
        GrossSaleprice=Grosssaleprice;
    }

}

void FarmAnimal::setSellDate(bool setby,string SDate)
{


bool Valid=false;
    if(setby==true)
    {


        cout<<"Please enter the date the animal was sold in the form ##/##/##\n";

        getline(cin,SDate);
        Valid=CheckIfDateIsValid(SDate);   //Very specific date checking code is required as you will see below
                                           //in the definition of this function.
       if (Valid==true){
        SellDate=SDate;

        }
        else if(Valid==false) {
            cout<<"The Data you entered is either invalid data or is in the incorrect format. Try again\n";
            setSellDate(true);

                              }
    }
    else if (setby==false)
    {
        setSoldFlag(0);
        SellDate=SDate;
    }

}

void FarmAnimal::setSoldFlag(int thesoldflag)
{
    SoldFlag=thesoldflag;
}

string FarmAnimal::getAnimalid()
{
    return Animalid;
}

int FarmAnimal::getInWeight()
{
    return InWeight;
}


int FarmAnimal::getOutWeight()
{
    return OutWeight;
}


int FarmAnimal::getCost()
{
    return Cost;
}

int FarmAnimal::getAvCostProcess()
{
    return AvCostProcess;

}

string FarmAnimal::getSex()
{
    return Sex;

}

string FarmAnimal::getBreed()
{
    return Breed;
}

string FarmAnimal::getSupplierName()
{
    return SupplierName;
}

string FarmAnimal::getBoughtDate()
{
    return BoughtDate;
}

float FarmAnimal::getRetailPricePerkg()
{
    return RetailPricePerkg;
}


float FarmAnimal::getGrossSaleprice()
{
    return GrossSaleprice;
}


string FarmAnimal::getSellDate()
{
    return SellDate;
}
int FarmAnimal::getSoldFlag()
{
    return SoldFlag;
}








FarmAnimal& FarmAnimal::operator=(FarmAnimal& RHS)
{

    if (this!=&RHS)
    {

        Animalid=RHS.getAnimalid();
        Cost=RHS.getCost();
        GrossSaleprice=RHS.getGrossSaleprice();
        SupplierName=RHS.getSupplierName();
        BoughtDate=RHS.getBoughtDate();
        SellDate=RHS.getSellDate();
        SoldFlag=RHS.getSoldFlag();
        InWeight=RHS.getInWeight();
        OutWeight=RHS.getOutWeight();
        Sex=RHS.getSex();
        RetailPricePerkg=RHS.getRetailPricePerkg();
        AvCostProcess=RHS.getAvCostProcess();
        Breed=RHS.getBreed();
    }

    return *this;

}

bool FarmAnimal::operator==(FarmAnimal& RHS)       //Overload equality operator maybe useful in this program or another.
{

    return ( Animalid==RHS.getAnimalid()&&
             Cost==RHS.getCost()&&
             GrossSaleprice==RHS.getGrossSaleprice()&&

             SupplierName==RHS.getSupplierName()&&
             BoughtDate==RHS.getBoughtDate()&&
             SellDate==RHS.getSellDate()&&
             SoldFlag==RHS.getSoldFlag()&&
             InWeight==RHS.getInWeight()&&
             OutWeight==RHS.getOutWeight()&&
             Sex==RHS.getSex()&&
             RetailPricePerkg==RHS.getRetailPricePerkg()&&
             AvCostProcess==RHS.getAvCostProcess()&&
             Breed==RHS.getBreed());



}

  bool FarmAnimal::CheckIfAnimalIdIsValid(string AnimalId)
{                                                                // A farm animal id is 12 digits in length so
                                                                 // check for data length and integrity here.


bool Valid=false;
int len=0;
int i=0;

len=AnimalId.length();

if(len!=12){
    return false;
           }
else if(len==12){

 for(i=0;i<12;i++){
    if( (AnimalId[i]>='0')&&(AnimalId[i]<='9') ){
        Valid=true;
        continue;
                                                }
    else if(  !(  (AnimalId[i]>='0')&&(AnimalId[i]<='9') ) ){
    Valid=false;
    break;
                                                            }


                  }

                }
if ( (i==12)&&(Valid==true) ){

    return true;
                             }
else {
    return false;
     }


}

bool FarmAnimal::CheckIfYearIsValid(string Year){  //Integrity of all entered data must be ensured

bool Valid=false;
int len=0;
int i=0;


len=Year.length();
cout<<"\n";
cout<<len;
cout<<"\n";
if (len!=3){

    Valid=false;
    return Valid;
           }


for(i=0;i<len;i++){
    if(i==0){
        if(Year[i]!='/'){

        Valid=false;
        break;
                        }
            }
    else if(i==1){
        if(  !((Year[i]>='0')&&(Year[i]<='9'))  ){
            Valid=false;
            break;
                                                 }
                 }
   else if(i==2){
    if(   !((Year[i]>='0')&&(Year[i]<='9'))  ){
        Valid=false;
        break;
                                              }
   else if((Year[i]>='0')&&(Year[i]<='9')){

    Valid=true;

    break;
                                          }
   }

                     }


return Valid;
}




bool FarmAnimal::CheckIfStringIsValid(string name)   //Again, Integrity of entered or queried data must be ensured
{


bool Valid=false;
//char ch;
int len=0;
int i=0;
int CheckLenValue=0;



        len=name.length();

            for(i=0;i<len;i++){
                if (! (    ((name[i])>='a'&&(name[i])<='z')||((name[i])==' ')||((name[i])>='A'&&(name[i])<='Z')  )) // Must be ok to include a space
                    {
                 if(i==(len-1)) {
                    CheckLenValue=1;
                                }
                 break;
                    }
                              }

             if(   (i==(len))&&(CheckLenValue==0)) //Only return Valid if ALL string members are valid
                {
                    Valid=true;

                }
            else if(i<(len-1)|| ((i==(len-1))&&(CheckLenValue==1)))
                {
                Valid=false;


                }
    return Valid;
}


bool FarmAnimal::CheckIfDateIsValid(string Date)     //Choose a specific date format and stick to it.
{

int len=0;
bool Valid=false;


len=Date.length();       //Each and every element of the string must be checked



       for(;;) {

        if((len!=8)||(Date[2]!='/')||(Date[5]!='/')) {
            Valid=false;
            break;

                                                     }
        else if (   ((Date[0]!='0')&&(Date[0]!='1')&&(Date[0]!='2')&&(Date[0]!='3'))||  (!((Date[1]>='0')&&(Date[1]<='9')))      )
           {

           Valid=false;
           break;
           }
        else if ((Date[0]=='3')&& (!(  (Date[1]=='0')||(Date[1]=='1'))))
            {
            Valid=false;
            break;
            }
        else if( (!( (Date[3]=='0')||(Date[3]=='1')))|| (!(  (Date[4]>='0')&&(Date[4]<='9') )))
            {
            Valid=false;
              break;

            }
         else if(  (Date[3]=='1')&& (!((Date[4]=='0')||(Date[4]=='1')||(Date[4]=='2')))  ){
            Valid=false;
            break;
         }
         else if(  (!((Date[6]>='0')&&(Date[6]<='9')))||(!((Date[7]>='0')&&(Date[7]<='9')))){
            Valid=false;
            break;
         }
        else {Valid=true;
              break;
       }
             }

        return Valid;


}




Counter::Counter()     // Counter is an object and as such should be designed as a class
{                      // object with formal class mechanisms.

    Count=new int;
    *Count=0;
}
Counter::~Counter()
{
    delete Count;
}

Counter::Counter(Counter& RHS)
{

    Count= new int;
    *Count=RHS.GetCounter();
}

void Counter::SetCounter(int sCount)
{
    *Count=sCount;

}


int Counter::GetCounter(void)
{

    return *Count;
}


Counter& Counter::operator++()     //prefix operator
{

    ++(*Count);
    return *this;

}
Counter Counter::operator++(int theflag)     //postfix operator
{

    Counter temp(*this);
    ++(*Count);
    return temp;

}

Counter& Counter::operator--()
{
    --(*Count);
    return *this;
}



AnimalContainer::AnimalContainer(int theSize)

{
    Size=theSize;
    int j=0;

    container= new FarmAnimal[Size];        // So as to formulate a whole array of animal objects in the freestore.


    for(j=0; j<Size; j++)

    {

        container[j].setAnimalid();         // Good practice to initialize all members with generic data in constructor.
        container[j].setCost();
        container[j].setGrossSaleprice();
        container[j].setSupplierName();
        container[j].setBoughtDate();
        container[j].setSellDate();
        container[j].setInWeight();
        container[j].setOutWeight();
        container[j].setSex();
        container[j].setRetailPricePerkg();
        container[j].setAvCostProcess();
        container[j].setBreed();
    }


}

AnimalContainer::~AnimalContainer()
{

    delete [] container;
    container=NULL;       //Avoid stray pointers
}



AnimalContainer::AnimalContainer(AnimalContainer& RHS)
{
    int j=0;

    container= new FarmAnimal[Size];


    for(j=0; j<Size; j++)

    {



        container[j]=RHS.container[j];   // Copy constructor making use of overloaded equals operator.

    }

}




AnimalContainer& AnimalContainer::operator=(AnimalContainer &RHS)   //So as to utilize in copy constructor
{

    int i=0;

    if (this==&RHS)
        return *this;
    delete[] container;

    container=new FarmAnimal[Size];
    for(i=0; i<Size; i++)
    {


        container[i]=RHS.container[i];
    }
    return *this;
}



void AnimalContainer::Fillcontainer(Counter& CountFilled)     // Counter object should be passed by reference
{                                                             // to container functions to register a change
    CountFilled.SetCounter(0);                                // in number of container members.
    int j=0;

    for(j=0; j<3; j++)

    {
        container[j].setAnimalid(false,"0");                  // Fill with generic data for testing and debugging
        container[j].setCost(false,5);                        // purposes.
        container[j].setGrossSaleprice(false,6.1);
        container[j].setSupplierName(false,"wmcdonnell");
        container[j].setBoughtDate(false,"##/##/##");
        container[j].setSellDate(false,"##/##/##");
        container[j].setInWeight(false,250);
        container[j].setOutWeight(false,850);
        container[j].setSex(false,"m");
        container[j].setRetailPricePerkg(false,3.2);
        container[j].setAvCostProcess(false,450);
        container[j].setBreed(false,"frecian");
        ++CountFilled;
    }

}

int AnimalContainer::VerifyCount(Counter& CountFilled)    // A checking mechanism to verify Count is correct.
{

    int i=0;
    int CheckCount=0;

    while(i!=Size)
    {

        if ((container[i].getAnimalid()>"0")&&(container[i].getCost()>0)&&(container[i].getGrossSaleprice()>0)) // No need to check all variables.
        {
            CheckCount++;
            i++;
        }
        else if (container[i].getAnimalid()=="0")
        {
            i++;
        }
    }

    if (CountFilled.GetCounter()!=CheckCount)
    {


        cout<<"There has been an error in the number of animals recorded in the database which is now being corrected\n";

        CountFilled.SetCounter(CheckCount);  // Counter should be corrected if an error has been encountered.
        return 0;

    }
    else if(CountFilled.GetCounter()==CheckCount)
    {

        cout<<"Count has been verified and is correct\n";
        cout<<"\n";
        return 0;
    }
    return 0;

}


bool AnimalContainer::IfMaxReached(Counter& CountFilled)    // The user should be notiified if container is at
{                                                           // or nearing full capacity so as to make more room.



    if (CountFilled.GetCounter()<(Size-10))
    {

        return false;
    }

    else if ((CountFilled.GetCounter()>(Size-11))&&(CountFilled.GetCounter()<(Size-1)))
    {
        cout<<"You have almost reached the maximum number of animal detail entries allowed\n";
        return false;
    }

    else if (CountFilled.GetCounter()==(Size-1))
    {
        cout<<"You have reached the maximum number of members allowed in the Database\n";
        cout<<"Delete enough members to make more space or ask your administrator for assistance\n";
        return true;
    }
    return false;
}

void AnimalContainer::DisplayMember(int offset)
{




    cout<<container[offset].getAnimalid();                    //Getting alignment right for landscape view is important.
    cout<<"   ";cout<<container[offset].getBreed();
    cout<<"     ";cout<<container[offset].getSex();
    cout<<"        ";cout<<container[offset].getInWeight();
    cout<<"        ";cout<<container[offset].getCost();
    cout<<"     ";cout<<container[offset].getBoughtDate();
    cout<<"   ";cout<<container[offset].getSellDate();
    cout<<"       ";cout<<container[offset].getAvCostProcess();
    cout<<"                  ";cout<<container[offset].getOutWeight();
    cout<<"             ";cout<<container[offset].getRetailPricePerkg();
    cout<<"               ";cout<<container[offset].getGrossSaleprice();
    cout<<"        ";cout<<container[offset].getSupplierName();

    cout<<"\n";
}


int AnimalContainer::search(FarmAnimal *Temps,Counter& CountFilled) // Search should be overloaded...one type for search and
{                                                                   // display and another to check for presence supporting
    bool Valid=false;                                               // create and delete functions.
    int j;
    string IDtosearch;
    char ch;

    cin.get(ch);
    cout<<"please enter an ID number to search for\n\n";
    VerifyCount(CountFilled);


    if(CountFilled.GetCounter()>0)
    {

    getline(cin,IDtosearch);
    Valid=container[0].CheckIfAnimalIdIsValid(IDtosearch);    //Screen Id entered to ensure it is a valid format.

        while(Valid==false)
        {
        cout<<"Invalid ID or incorrect format, try again\n\n"; // Do not proceed until format entered is correct.
            getline(cin,IDtosearch);
            cout<<"\n";
            Valid=container[0].CheckIfAnimalIdIsValid(IDtosearch);
        }

        for(j=0; j<CountFilled.GetCounter(); j++)
    {

        if (container[j].getAnimalid()==IDtosearch)
        {

            *Temps= container[j];
            cout<<"this animal is a member of the database and here are it's details:\n\n"; //For user convenience, display if found.

            cout<<"AnimalID        ";cout<<"Breed       ";cout<<"Sex  ";cout<<"InWeight(kgs) ";cout<<"Cost    "; cout<<"BoughtDate  ";cout<<"SellDate  ";cout<<"AverageCostProcesses  ";cout<<"Outweight(kgs)  ";cout<<"RetailPrice/Kg  ";cout<<"GrossSalePrice  ";cout<<"SupplierName\n\n";
            cout<<Temps->getAnimalid();
    cout<<"   ";cout<<Temps->getBreed();
    cout<<"     ";cout<<Temps->getSex();
    cout<<"        ";cout<<Temps->getInWeight();
    cout<<"        ";cout<<Temps->getCost();
    cout<<"     ";cout<<Temps->getBoughtDate();
    cout<<"   ";cout<<Temps->getSellDate();
    cout<<"       ";cout<<Temps->getAvCostProcess();
    cout<<"                  ";cout<<Temps->getOutWeight();
    cout<<"             ";cout<<Temps->getRetailPricePerkg();
    cout<<"               ";cout<<Temps->getGrossSaleprice();
    cout<<"        ";cout<<Temps->getSupplierName();

    cout<<"\n";

            break;
            }
        else if ((container[j].getAnimalid()!=IDtosearch)&&(j!=CountFilled.GetCounter()-1)) //skip over if not a member
        {

            continue;
        }
        else if((container[j].getAnimalid()!=IDtosearch)&&(j==CountFilled.GetCounter()-1)) //end search if not found
        {

            cout<<"Animal ID not a member\n\n";
            break;
        }


    }
      }
    else if(CountFilled.GetCounter()==0)
    {
        cout<<"Container is empty. Return to main menu\n";
        return 0;
    }


    return 0;
}

int AnimalContainer::search(FarmAnimal *Temps,bool *ifpresent,Counter& CountFilled)   // To support create and delete functions.

{
    *ifpresent=false;       //Has been passed by reference as indicator when part of external function.
    int j;
    int MemberNumber=0;
    for(j=0; j<CountFilled.GetCounter(); j++)
    {

        if (container[j].getAnimalid()==Temps->getAnimalid())
        {

            *ifpresent=true;
            MemberNumber=j;
            break;
        }
        else if (j==(CountFilled.GetCounter()-1))
        {

            *ifpresent=false;
            break;
        }
        else if(j<CountFilled.GetCounter())
        {
            continue;
        }

    }
    return MemberNumber;

}

int AnimalContainer::CreateNewMember(FarmAnimal *tempc,Counter& CountFilled)
{
    char  ch;
    bool ifispresent=false;
    bool CapacityVal=false;
    int SalesFlag=0;
    cout<<"Please enter the details of the Animal you wish to create\n";

    cin.get(ch);
    tempc->setAnimalid(true);              // Use a temporary object first to and ensure is not a member
    tempc->setCost(true);                  // before added to container.
    tempc->setSupplierName(true);
    tempc->setBoughtDate(true);
    tempc->setInWeight(true);
    tempc->setSex(true);
    tempc->setBreed(true);

    cout<<"Do you have sales data to enter? Select 1 for yes or 0 for no.\n";
    cin>>SalesFlag;
    if((SalesFlag!=1)&&(SalesFlag!=0))
        {
        cout<<"That is an invalid entry. Return to Your main menu and try again\n";
                                      return 0;
        }
    else if(SalesFlag==0)
    {

    tempc->setSellDate();
    tempc->setOutWeight();
    tempc->setRetailPricePerkg();
    tempc->setAvCostProcess();


    }
    else if(SalesFlag==1)
    {
    cin.get(ch);
    tempc->setSellDate(true);
    tempc->setOutWeight(true);
    tempc->setRetailPricePerkg(true);
    tempc->setAvCostProcess(true);

    }

    search(tempc,&ifispresent,CountFilled);

    if(!(ifispresent))                        // Must ensure not already present before adding to container.
    {
        CapacityVal=IfMaxReached(CountFilled);  // Must check for sufficient space in container
                                                // before attempting to add.
        if ( CapacityVal==true ){
        return 0;
                                }
        else if (CapacityVal==false){
        VerifyCount(CountFilled);
        InsertNewMember(tempc,CountFilled);

                                    }
    else if (ifispresent)
    {

        cout<<"the member you entered is already a member of the database.\n"; // The user should be notified if attempting
        cout<<"Duplicate entries are not allowed\n";                           // to add a member that's already present.
    }
    }
    return 0;

}

int AnimalContainer::DeleteMember(FarmAnimal *tempc,Counter& CountFilled)  // temp object available so as to pass by referencce
{                                                                          // Counter passed by reference to permanently
                                                                           // record a change if is to be decremented.
    int SortCounter=0;
    bool IfPresent=false;
    int Membernumber=0;
    char ch;
    cin.get(ch);

    VerifyCount(CountFilled);

    if(CountFilled.GetCounter()>0)  {

    cout<<"Please enter the details of the Animal you wish to delete\n";

    tempc->setAnimalid(true);          // Must allow user to enter Id.
    tempc->setCost();
    tempc->setGrossSaleprice();
    tempc->setSupplierName();
    tempc->setBoughtDate();
    tempc->setSellDate();
    tempc->setInWeight();
    tempc->setOutWeight();
    tempc->setSex();
    tempc->setRetailPricePerkg();
    tempc->setAvCostProcess();
    tempc->setBreed();


    Membernumber=search(tempc,&IfPresent,CountFilled);      // Only attempt a delete if already present.

    if ((IfPresent)&&(Membernumber!=(CountFilled.GetCounter()-1)))
    {

        container[Membernumber].setAnimalid();                       // Must firstly zero or neutralize member to delete
        container[Membernumber].setCost();
        container[Membernumber].setGrossSaleprice();
        container[Membernumber].setSupplierName();
        container[Membernumber].setBoughtDate();
        container[Membernumber].setSellDate();
        container[Membernumber].setInWeight();
        container[Membernumber].setOutWeight();
        container[Membernumber].setSex();
        container[Membernumber].setRetailPricePerkg();
        container[Membernumber].setAvCostProcess();
        container[Membernumber].setBreed();

        SortCounter=(CountFilled.GetCounter()-(Membernumber+1));

        while (SortCounter!=0)                                     // If not last member
        {                                                          // each member must be shifted one place to ensure
                                                                   // container will not have unfilled members.

            container[Membernumber]=container[Membernumber+1];

            container[Membernumber+1].setAnimalid();
            container[Membernumber+1].setCost();
            container[Membernumber+1].setGrossSaleprice();
            container[Membernumber+1].setSupplierName();
            container[Membernumber+1].setBoughtDate();
            container[Membernumber+1].setSellDate();
            container[Membernumber+1].setInWeight();
            container[Membernumber+1].setOutWeight();
            container[Membernumber+1].setSex();
            container[Membernumber+1].setRetailPricePerkg();
            container[Membernumber+1].setAvCostProcess();
            container[Membernumber+1].setBreed();

            Membernumber++;
            SortCounter--;
        }

        --CountFilled;
        cout<<"The animal member with id number\t";
        cout<<tempc->getAnimalid();
       cout<<"\t";
        cout<<"has now been deleted from the container\n";
    }

    else if ((IfPresent)&&(Membernumber==(CountFilled.GetCounter()-1)))    // No need to implement shift if member is last.
    {

        container[Membernumber].setAnimalid();
        container[Membernumber].setCost();
        container[Membernumber].setGrossSaleprice();
        container[Membernumber].setSupplierName();
        container[Membernumber].setBoughtDate();
        container[Membernumber].setSellDate();
        container[Membernumber].setInWeight();
        container[Membernumber].setOutWeight();
        container[Membernumber].setSex();
        container[Membernumber].setRetailPricePerkg();
        container[Membernumber].setAvCostProcess();
        container[Membernumber].setBreed();

        --CountFilled;
        cout<<"The animal member with id number\t";
        cout<<tempc->getAnimalid();
        cout<<"\t";
        cout<<"has now been deleted from the container\n";
    }
    else if (!IfPresent)
    {
        cout<<"The member you entered is not a member of the database\n";
    }
                                                     }
    else if(CountFilled.GetCounter()==0)
    {
    cout<<"The container is empty. Return to main menu\n";
       return 0;
    }

    return 0;
}

int AnimalContainer::Amend(FarmAnimal *tempc,Counter &CountFilled)   // User may want option to amend an existing member.
{
    int MemberNumber=0;
    char ch;
    bool Valid=false;
    bool EnsurePresence=false;
    int Affirmation=0;

    string AnimalID="0";
    int SalesFlag=0;

    cin.get(ch);
    VerifyCount(CountFilled);

    if (CountFilled.GetCounter()>0) {

    cout<<"Please enter the ID number of the Animal whose details you wish to amend\n";

    getline(cin,AnimalID);
    Valid=container[0].CheckIfAnimalIdIsValid(AnimalID);

        while(Valid==false){                                      // Force user to enter an ID with valid format(12 digits).
        cout<<"Invalid ID or incorrect format, try again\n";
            getline(cin,AnimalID);
            Valid=container[0].CheckIfAnimalIdIsValid(AnimalID);
                           }




    tempc->setAnimalid(false,AnimalID);

    MemberNumber=search(tempc,&EnsurePresence,CountFilled);

    if (EnsurePresence==false)                             // Must check to ensure presence firstly.
    {

        cout<<"No such animal details exist which are compatible with the ID number you provided\n\n";
        return 0;
    }
    else if (EnsurePresence==true)    //Should present member to user to gain confirmation
    {

        cout<<"here are the animal details compatible with the id number which you provided:\n\n";
        cout<<"AnimalID        ";cout<<"Breed       ";cout<<"Sex  ";cout<<"InWeight(kgs)  ";cout<<"Cost    "; cout<<"BoughtDate  ";cout<<"SellDate  ";cout<<"AverageCostProcesses  ";cout<<"Outweight(kgs)  ";cout<<"RetailPrice/Kg  ";cout<<"GrossSalePrice  ";cout<<"SupplierName\n\n";
        DisplayMember(MemberNumber);

        cout<<"Are these the Animal details you wish to amend?? Enter 1 for yes or 0 for no.\n";
        cout<<"\n\n";

        cin>>Affirmation;

        if (Affirmation==1)
        {
            cout<<"Please update all of this animals details\n\n";
            cin.get(ch);



            container[MemberNumber].setAnimalid(true);
            container[MemberNumber].setCost(true);
            container[MemberNumber].setSupplierName(true);
            container[MemberNumber].setBoughtDate(true);
            container[MemberNumber].setInWeight(true);
            container[MemberNumber].setSex(true);
            container[MemberNumber].setBreed(true);

            cout<<"Do you need to update Sales details? Enter 1 for yes or 0 for no.\n";
            cin>>SalesFlag;
            if((SalesFlag!=0)&&(SalesFlag!=1))
            {

                cout<<"That is an invalid entry. Please return to your Main Menu and try again\n";
                return 0;
            }
            else if(SalesFlag==0)
            {

            container[MemberNumber].setSellDate();
            container[MemberNumber].setOutWeight();
            container[MemberNumber].setRetailPricePerkg();
            container[MemberNumber].setAvCostProcess();
            container[MemberNumber].setGrossSaleprice();
            }
            else if(SalesFlag==1){
            cin.get(ch);
            container[MemberNumber].setSellDate(true);
            container[MemberNumber].setOutWeight(true);
            container[MemberNumber].setRetailPricePerkg(true);
            container[MemberNumber].setAvCostProcess(true);

                                 }


            cout<<"Animal Details have now been amended\n";
            return 0;
        }
        else if (Affirmation!=1)
        {
            cout<<"try Again\n";
            Amend(tempc,CountFilled);              // Should continue to request an ID until until confirmation is gained
                                                   // by using recursion.
        }

    }
    }
    else if(CountFilled.GetCounter()==0)
    {
        cout<<"The container is empty, return to main menu\n";
        return 0;
     }


    return 0;
}



void AnimalContainer::InsertNewMember(FarmAnimal *Temps,Counter& CountFilled)
{


    container[CountFilled.GetCounter()]=(*Temps);

    ++CountFilled;
cout<<"Your new member has now been added to the database\n";
}


int AnimalContainer::DisplayContainerMembers(Counter& CountFilled)

{

    VerifyCount(CountFilled);

    if (CountFilled.GetCounter()==0) {                           // Controlled and dependant on counter value.
        cout<<"There is no data in the container to save, return to main menu\n";
        return 0;

                                     }

    else if(CountFilled.GetCounter()>0){

        cout<<"AnimalID        ";cout<<"Breed       ";cout<<"Sex  ";cout<<"InWeight(kgs)  ";cout<<"Cost    "; cout<<"BoughtDate  ";cout<<"SellDate  ";cout<<"AverageCostProcesses  ";cout<<"Outweight(kgs)  ";cout<<"RetailPrice/Kg  ";cout<<"GrossSalePrice  ";cout<<"SupplierName\n\n";


for(int j=0; j<CountFilled.GetCounter(); j++)
    {

        DisplayMember(j);

    }
        }
return 0;
}




Fileprocesses::Fileprocesses(int Size): AnimalContainer(Size){}   // Size of container must percolate upwards to base class.

Fileprocesses::~Fileprocesses() {}


int Fileprocesses::LoadFromFile(Counter& CountFilled)     // Two types of file...one for saving data and the
{                                                        // other for presenting data in a report



    char FileName[20];
    string animalid;
    int cost;
    int inweight;
    int avcostprocess;
    int soldflag;
    int outweight;
    float Grosssaleprice;
    float retailpricePerkg;
    string suppliername;
    string boughtdate;
    string breed;
    string sex;
    string selldate;


    int i=0;
    int counter=0;
    char ch;

    cout<<"enter the name of your file\n";
    cin>>FileName;


    ifstream fin;
    fin.open(FileName);

    if (!fin)
    {

        cout<<"problem opening file for reading\n";    // Must error check for opening of file.
        return (1);

    }

     fin>>counter;         // Counter must be the first object/variable stored to control intake of data.

     if(counter==0)
     {
         cout<<"There is no data saved to file, return to your main menu\n";
     }
    else { CountFilled.SetCounter(counter);

         }


    for(i=0;i<CountFilled.GetCounter();i++)
    {

        fin>>animalid;                              // Order of writing to file and reading from file must be the same.
        container[i].setAnimalid(false,animalid);
        fin.get(ch);
        getline(fin,suppliername);
        container[i].setSupplierName(false,suppliername);
        fin>>boughtdate;
        container[i].setBoughtDate(false,boughtdate);
        fin.get(ch);
        getline(fin,breed);
        container[i].setBreed(false,breed);
        fin>>sex;
        container[i].setSex(false,sex);
        fin>>cost;
        container[i].setCost(false,cost);
        fin>>inweight;
        container[i].setInWeight(false,inweight);
        fin>>avcostprocess;
        container[i].setAvCostProcess(false,avcostprocess);
        fin>>retailpricePerkg;
        container[i].setRetailPricePerkg(false,retailpricePerkg);
        fin>>selldate;
        container[i].setSellDate(false,selldate);
        fin>>soldflag;
        container[i].setSoldFlag(soldflag);
        fin>>outweight;
        container[i].setOutWeight(false,outweight);
        fin>>Grosssaleprice;
        container[i].setGrossSaleprice(false,Grosssaleprice);


      }
    fin.close();
 VerifyCount(CountFilled);



    return 0;
}

int Fileprocesses::SaveToFile(Counter& CountFilled)
{


    char Filename[20];
    int i=0;

    cout<<"enter the name of your file\n";
    cin>>Filename;

    if (Filename==NULL)
    {

        return 0;
    }

    ofstream fout(Filename,ios::binary);

    if (!fout)
    {
        cout<<"unable to open file to write\n";
        return (1);
    }
    VerifyCount(CountFilled);                      // Count should always be verified before writing to file
    if (CountFilled.GetCounter()==0) {             // to ensure it is at the correct level before saving.
        cout<<"There is no data in the container to save, return to main menu\n";
        return 0;

                                     }
else
    fout<<CountFilled.GetCounter();
    fout<<"\n";

    for (i=0; i<CountFilled.GetCounter(); i++)    // Only output rhe number of entries that are filled with authentic data.
    {




        fout<<container[i].getAnimalid();
        fout<<"\n";
        fout<<container[i].getSupplierName();
        fout<<"\n";
        fout<<container[i].getBoughtDate();
        fout<<"\n";
        fout<<container[i].getBreed();
        fout<<"\n";
        fout<<container[i].getSex();
        fout<<"\n";
        fout<<container[i].getCost();
        fout<<"\n";
        fout<<container[i].getInWeight();
        fout<<"\n";
        fout<<container[i].getAvCostProcess();
        fout<<"\n";
        fout<<container[i].getRetailPricePerkg();
        fout<<"\n";
        fout<<container[i].getSellDate();
        fout<<"\n";
        fout<<container[i].getSoldFlag();
        fout<<"\n";
        fout<<container[i].getOutWeight();
        fout<<"\n";
        fout<<container[i].getGrossSaleprice();
        fout<<"\n";



    }


    fout.close();


    return 0;

}





int Fileprocesses::PrintAsReport(Counter& CountFilled){     // This function necessary to provide presentable version of data
                                                            // to user.


    char Filename[20];
    int i=0;

    VerifyCount(CountFilled);

    if (CountFilled.GetCounter()==0) {
        cout<<"There is no data in the container to save, return to main menu\n";
        return 0;

                                     }

    else if(CountFilled.GetCounter()>0)
        {


    cout<<"enter the name of your file for printing\n";
    cin>>Filename;

    if (Filename==NULL)
    {

        return 0;
    }

    ofstream fout(Filename,ios::binary);

    if (!fout)
    {
        cout<<"unable to open file to write\n";
        return (1);
    }

        //Care must be taken to format output of data.
        fout<<"AnimalID        ";fout<<"Breed       ";fout<<"Sex  ";fout<<"InWeight(kgs)  ";fout<<"Cost    "; fout<<"BoughtDate  ";fout<<"SellDate  ";fout<<"AverageCostProcesses  ";fout<<"Outweight(kgs)  ";fout<<"RetailPrice/Kg  ";fout<<"GrossSalePrice  ";fout<<"SupplierName\n\n";


for(i=0;i<CountFilled.GetCounter();i++) {

    fout<<container[i].getAnimalid();
    fout<<"   ";fout<<container[i].getBreed();   //Care must be taken to format output of data.
    fout<<"     ";fout<<container[i].getSex();
    fout<<"        ";fout<<container[i].getInWeight();
    fout<<"        ";fout<<container[i].getCost();
    fout<<"     ";fout<<container[i].getBoughtDate();
    fout<<"   ";fout<<container[i].getSellDate();
    fout<<"       ";fout<<container[i].getAvCostProcess();
    fout<<"                  ";fout<<container[i].getOutWeight();
    fout<<"             ";fout<<container[i].getRetailPricePerkg();
    fout<<"               ";fout<<container[i].getGrossSaleprice();
    fout<<"        ";fout<<container[i].getSupplierName();

    fout<<"\n";
                                         }

          fout.close();
          }


return 0;
}



ProcessClass::ProcessClass(int Size): Fileprocesses(Size) {}  // Size of container must percolate upwards to base class.

ProcessClass::~ProcessClass() {}

int ProcessClass::TotalCostbySupplierName(Counter& CountFilled)  // Define collection of data in accordance with different
{                                                                // types of keys.
    char ch;
    int i=0;
    string Suppliername;
    int OptionCheck=0;
    int TotalCosts=0;

    cout<<"You have selected the option to calculate total cost of animals\n";
    cout<<"accumulated which came from a particular supplier. please verify this is your option\n";
    cout<<"Please enter 1 for yes or 0 for no.\n\n";
    cin>>OptionCheck;                                       // To ascertain option choice verification from user

    if((OptionCheck!=0)&&(OptionCheck!=1))                  // To verify from user that option chosen is intended option.
    {
        cout<<"The data you entered for this request is non valid.\n";
        cout<<"Go back to the menu and choose an option again\n";
        return 0;
    }

    else if(OptionCheck==0)
    {

        return 0;
    }
    else if(OptionCheck==1)
    {

        VerifyCount(CountFilled);

        if (CountFilled.GetCounter()==0)
        {

            cout<<"There is no information in the database to process\n";     // User must be infoemed if container is empty.
            return 0;
        }
        else if (CountFilled.GetCounter()>0)
        {
            cout<<"please enter the name of the supplier whose animal costs you wish to total\n";

            cin.get(ch);
            getline(cin,Suppliername);

            while(!container[0].CheckIfStringIsValid(Suppliername)){           // Force user to enter valid data before proceeding.
                cout<<"The data you entered is invalid. Please try again\n";
            getline(cin,Suppliername);

        }

            for(i=0; i<CountFilled.GetCounter(); i++)
            {
                if(Suppliername==container[i].getSupplierName())
                {

                    TotalCosts=TotalCosts+container[i].getCost()+container[i].getAvCostProcess();
                    continue;
                }
                else if(Suppliername!=container[i].getSupplierName())
                    continue;
            }

        }
    }

    if (TotalCosts>0)
    {

        cout<<"The total costs incurred via the supplier you submitted are\n";
        cout<<TotalCosts;
        cout<<"\n";
    }
    else{
        cout<<"The supplier you entered either has no costs associated with him/her\n";  // Always remember a name entered may be valid
        cout<<"or the name is not a member of the database\n";                           //but may have no corresponding data in container.
        }
    return 0;
}

int ProcessClass::TotalCostbyDateSold(Counter& CountFilled){   // Various choices/keys for accumulating data.

char ch;
int i=0;
int OptionCheck=0;
int TotalCosts=0;
string date;

cout<<"You have selected the option to calculated total costs incurred\n";
cout<<"by animals sold on a particular date. Please verify that you wish\n";
cout<<"to proceed with this option. Enter 1 for yes or 0 for no\n";

cin>>OptionCheck;

if ((OptionCheck!=0)&&(OptionCheck!=1))
    {

    cout<<"The data you entered is invalid. Please return to menu\n";
    return 0;
    }
  else if(OptionCheck==0)
  {

    return 0;
  }
else if (OptionCheck==1){

    VerifyCount(CountFilled);

    if(CountFilled.GetCounter()==0){

        cout<<"The Database is empty. Please return to menu and inform\n";
        cout<<"the administrator\n";
        return 0;
                                   }
        else if(CountFilled.GetCounter()>0){

            cout<<" Plese enter the date in the form ##/##/## that\n";
            cout<<" the Animals were sold on for whose total costs\n";
            cout<<" you wish to calculate\n";

           cin.get(ch);
           getline(cin,date);

            while (!container[0].CheckIfDateIsValid(date))      // Outsourcing the check for valid data to base class.
            {
                cout<<"That is not a valid date or format is incorrect\n";
                cout<<"Please re-enter the date in the correct format\n";
                getline(cin,date);
            }
            for(i=0;i<CountFilled.GetCounter();i++){

                if(date==container[i].getSellDate()){
                    TotalCosts=(TotalCosts+container[i].getCost()+container[i].getAvCostProcess());
                    continue;
                                                    }
                    else if(date!=container[i].getSellDate()){

                        continue;
                                                             }


                                                   }

            if(TotalCosts>0){
                cout<<"Here are the total costs incurred by the animals sold\n";
                cout<<"on the date that you entered\t"<<TotalCosts;
                cout<<"\n";
                            }
                else if(TotalCosts==0){

                    cout<<"There are no costs entered representing cost incurrance\n";
                    cout<<"for animals sold on the date which you entered or\n";
                    cout<<"there were no animals sold on that date\n";
                    cout<<"return to menu\n";
                    return 0;
                }
            }


                     }

return 0;
}

int ProcessClass::TotalCostsInYear(Counter& CountFilled)
{

char ch;
int i=0;
int OptionCheck=0;
int TotalCosts=0;
string YearRequest;
string DatabaseYear;

cout<<"You have selected the option to calculated total costs incurred\n";
cout<<"by animals within a given year. Please verify that you wish\n";
cout<<"to proceed with this option. Enter 1 for yes or 0 for no\n";

cin>>OptionCheck;

if ((OptionCheck!=0)&&(OptionCheck!=1)){              // request verification from user that option chosen is intended one

    cout<<"The data you entered is invalid. Please return to menu\n";
    return 0;
                                       }
  else if(OptionCheck==0){

    return 0;
                         }
else if (OptionCheck==1){

    VerifyCount(CountFilled);

    if(CountFilled.GetCounter()==0){     // Should verify count is correct before gathering data.

        cout<<"The Database is empty. Please return to menu and inform\n";
        cout<<"the administrator\n";
        return 0;
                                   }
        else if(CountFilled.GetCounter()>0)
        {

            cout<<" Plese enter the year in the form /## that\n";
            cout<<" within which you wish to calculate costs\n";


           cin.get(ch);
           getline(cin,YearRequest);

            while (!container[0].CheckIfYearIsValid(YearRequest))    // Outsourcing the check for valid data to base class.
            {
                cout<<"That is not a valid year or format is incorrect\n";
                cout<<"Please re-enter the date in the correct format\n";
                getline(cin,YearRequest);
            }
            for(i=0;i<CountFilled.GetCounter();i++){

                DatabaseYear=container[i].getSellDate();

                if((YearRequest[0]==DatabaseYear[5])&&(YearRequest[1]==DatabaseYear[6])&&(YearRequest[2]==DatabaseYear[7]))
                                                       {
                    TotalCosts=(TotalCosts+container[i].getCost()+container[i].getAvCostProcess());
                    continue;
                                                       }
                    else {

                        continue;
                         }


                                                  }
        }
                       }



            if(TotalCosts>0){
                cout<<"Here are the total costs incurred by the animals sold\n";
                cout<<"on the date that you entered\t"<<TotalCosts;
                cout<<"\n";
                            }
                else if(TotalCosts==0){

                    cout<<"There are no costs entered representing cost incurrance\n";
                    cout<<"for animals sold in the year which you entered or\n";
                    cout<<"there were no animals sold on that date\n";
                    cout<<"return to menu\n";
                    return 0;
                                      }


return 0;


}





float ProcessClass::TotalRevenuebySupplierName(Counter& CountFilled){     //Different report options available

char ch;
int i=0;
int OptionCheck=0;
float TotalRevenues;
string SupplierName;

cout<<"You Have selected the option to calculate total revenues\n";
cout<<"Accumulated from animals bought from a particular supplier.\n";
cout<<"Please verify that you wish to proceed with this option.\n";
cout<<"Enter 1 for yes or zero for no\n";

cin>>OptionCheck;

if((OptionCheck!=0)&&(OptionCheck!=1))         // Allow user to verify option chosen is intended one
    {
    cout<<"You have entered data which is invalid. Please return to\n";
    cout<<"Please return to the menu\n";
    return 0;

    }
else if(OptionCheck==0){

    return 0;

                       }
else if(OptionCheck==1){

    VerifyCount(CountFilled);

    if(CountFilled.GetCounter()==0){

        cout<<"The database is empty. Please inform the administrator\n";
        cout<<"and return to the menu\n";

                                   }
    else if(CountFilled.GetCounter()>0){

        cout<<"Please enter the name of the supplier you wish to use\n";
        cout<<"to calculate total revenues for this group\n";
        cin.get(ch);
        getline(cin,SupplierName);

        while(!container[0].CheckIfStringIsValid(SupplierName))    // Outsource validation of data to base class.
            {
                cout<<"The data you entered is invalid. Please try again\n";
            getline(cin,SupplierName);

            }
        while(i<CountFilled.GetCounter()){

            if(SupplierName==container[i].getSupplierName())
            {

                TotalRevenues=(TotalRevenues+container[i].getGrossSaleprice());
                i++;
                continue;
            }

                else if(SupplierName!=container[i].getSupplierName())
                {

                    i++;
                    continue;
                }


                                                      }
            if (TotalRevenues==0){
            cout<<"There are no revenues for animals associated with that supplier\n";
            cout<<"or that supplier is not a member of the database\n";
            cout<<"Please return to the menu\n";

              return 0;
                                  }
            else if(TotalRevenues>0){

                cout<<"The total revenues for animals sold that were bought\n";
                cout<<"from the supplier name which you submitted are\t"<<TotalRevenues;
                cout<<"\n";
                                    }
            }



                          }
return 0;
}


float ProcessClass::TotalRevenuebyDateSold(Counter& CountFilled){

char ch;
int i=0;
int OptionCheck=0;
float TotalRevenues=0;
string Date;

cout<<"You Have selected the option to calculate total revenues\n";
cout<<"Accumulated from animals bought sold on a particular Date.\n";
cout<<"Please verify that you wish to proceed with this option.\n";
cout<<"Enter 1 for yes or zero for no\n";

cin>>OptionCheck;

if((OptionCheck!=0)&&(OptionCheck!=1))      // Allow user to verify option chosen is intended one.
    {
    cout<<"You have entered data which is invalid. Please return to\n";
    cout<<"Please return to the menu\n";
    return 0;

    }
else if(OptionCheck==0){

    return 0;

                       }
else if(OptionCheck==1){

    VerifyCount(CountFilled);     // Should always verify value of count before collection of data.

    if(CountFilled.GetCounter()==0){

        cout<<"The database is empty. Please inform the administrator\n";
        cout<<"and return to the menu\n";

                                   }
    else if(CountFilled.GetCounter()>0)
    {

        cout<<"Please enter the date of animals sold in the form ##/##/## you wish to use\n";
        cout<<"to calculate total revenues for this group\n";

        cin.get(ch);
        getline(cin,Date);
          while (!container[0].CheckIfDateIsValid(Date))               // Outsource validation of data to base class.
            {
                cout<<"That is not a valid date or format is incorrect\n";
                cout<<"Please re-enter the date in the correct format\n";
                getline(cin,Date);
            }
        while(i<CountFilled.GetCounter()){

            if(Date==container[i].getSellDate()){

                TotalRevenues=(TotalRevenues+container[i].getGrossSaleprice());
                i++;
                continue;
                                                }

                else if(Date!=container[i].getSellDate()){

                    i++;
                    continue;
                                                         }


                                          }
    }
                          }
            if (TotalRevenues==0)
            {
            cout<<"There are no revenues for animals associated with that date\n";
            cout<<"or no animals have been sold on that date\n";
            cout<<"Please return to the menu\n";

              return 0;
            }
            else if(TotalRevenues>0)
            {

                cout<<"The total revenues for animals sold that were bought\n";
                cout<<"from the supplier name which you submitted are\n";
                cout<<TotalRevenues;

                cout<<"\n";

            }





return 0;
}

float ProcessClass::TotalRevenueInYear(Counter& CountFilled)
{

char ch;
int i=0;
int OptionCheck=0;
int TotalRevenue=0;
string YearRequest;
string DatabaseYear;

cout<<"You have selected the option to calculate total revenue from\n";
cout<<"bovines within a particular year. Please verify that you wish\n";
cout<<"to proceed with this option. Enter 1 for yes or 0 for no\n";

cin>>OptionCheck;

if ((OptionCheck!=0)&&(OptionCheck!=1))    // Allow user to verify option chosen is intended one.
    {

    cout<<"The data you entered is invalid. Please return to menu\n";
    return 0;
    }
  else if(OptionCheck==0){

    return 0;
                         }
else if (OptionCheck==1)
{

    VerifyCount(CountFilled);

    if(CountFilled.GetCounter()==0){

        cout<<"The Database is empty. Please return to menu and inform\n";
        cout<<"the administrator\n";
        return 0;
                                   }
        else if(CountFilled.GetCounter()>0)
        {

            cout<<" Plese enter the year in the form /## that\n";
            cout<<" within which you wish to calculate revenues\n";


           cin.get(ch);
           getline(cin,YearRequest);

            while (!container[0].CheckIfYearIsValid(YearRequest))   // Outsource validation check of data to base class.
            {
                cout<<"That is not a valid date or format is incorrect\n";
                cout<<"Please re-enter the date in the correct format\n";
                getline(cin,YearRequest);
            }
            for(i=0;i<CountFilled.GetCounter();i++){

                DatabaseYear=container[i].getSellDate();

                if((YearRequest[0]==DatabaseYear[5])&&(YearRequest[1]==DatabaseYear[6])&&(YearRequest[2]==DatabaseYear[7]))
                                                       {
                    TotalRevenue=(TotalRevenue+container[i].getGrossSaleprice());
                    continue;
                                                    }
                    else {

                        continue;
                         }


                                                   }
        }
}



            if(TotalRevenue>0){
                cout<<"Here is the total revenue achieved by animals sold\n";
                cout<<"in the year which you provided\t"<<TotalRevenue;
                cout<<"\n";
                            }
                else if(TotalRevenue==0){

                    cout<<"There were no bovines sold within that year or\n";
                    cout<<"\n";

                    cout<<"return to menu\n";
                    return 0;
                                       }


return 0;

}



float ProcessClass::TotalProfitbySupplierName(Counter& CountFilled)
{

 char ch;
    int i=0;
    string Suppliername;
    int OptionCheck=0;
    int TotalCosts=0;
    float TotalRevenues=0;
    float TotalProfits=0;
    float TotalLosses=0;
    cout<<"You have selected the option to calculate total profits acrued\n";
    cout<<"by animals supplied by a particular supplier\n";
    cout<<"Please enter 1 for yes or 0 for no.\n\n";
    cin>>OptionCheck;                                       //To ascertain option choice verification from user.

    if((OptionCheck!=0)&&(OptionCheck!=1))
    {
        cout<<"The data you entered for this request is non valid.\n";
        cout<<"Go back to the menu and choose an option again\n";
        return 0;
    }

    else if(OptionCheck==0)
    {

        return 0;
    }
    else if(OptionCheck==1)
    {

        VerifyCount(CountFilled);

        if (CountFilled.GetCounter()==0)
        {

            cout<<"There is no information in the database to process\n";
            return 0;
        }
        else if (CountFilled.GetCounter()>0)
        {
            cout<<"please enter the name of the supplier associated with the animals\n";
            cout<<"whose profits you wish to calculate\n";

            cin.get(ch);
            getline(cin,Suppliername);

            while(!container[0].CheckIfStringIsValid(Suppliername)){     // Outsource validation of data to base class
                cout<<"The data you entered is invalid. Please try again\n";
            getline(cin,Suppliername);

        }

            for(i=0; i<CountFilled.GetCounter(); i++)
            {
                if(Suppliername==container[i].getSupplierName())
                {

                    TotalCosts=(TotalCosts+container[i].getCost()+container[i].getAvCostProcess());
                    TotalRevenues=(TotalRevenues+container[i].getGrossSaleprice());
                    continue;
                }
                else if(Suppliername!=container[i].getSupplierName())
                {
                    continue;
                }

        }
    }
    }
    if (TotalRevenues==0)
    {

        cout<<"Either the supplier name you provided is not a member of the database\n";
        cout<<"or there are no sales data entered for animals associated with that supplier\n";
        cout<<"name\n";
        cout<<"\n";
    }
    else if(TotalRevenues<TotalCosts) {                            //Allow for situation where money has been lost.
        TotalLosses=(TotalCosts-TotalRevenues);
        cout<<"You have lost money on bovines which were supplied by the\n";
        cout<<"supplier name which you provided. You have lost a total of\n";
        cout<<TotalLosses;
        cout<<"\t";
        cout<<"euros\n";

                                      }


    else if (TotalRevenues>TotalCosts){
        TotalProfits=(TotalRevenues-TotalCosts);
        cout<<"The total profits for bovines associated with the supplier\n";
        cout<<"name you entered are\n";
        cout<<TotalProfits;
        cout<<"\n";
                                      }
    return 0;
}


float ProcessClass::TotalProfitbyDateSold(Counter& CountFilled)

{
    char ch;
    int i=0;
    string Date;
    int OptionCheck=0;
    int TotalCosts=0;
    float TotalRevenues=0;
    float TotalProfits=0;
    float TotalLosses=0;

    cout<<"You have selected the option to calculate total profits acrued\n";
    cout<<"by animals supplied by a particular supplier\n";
    cout<<"Please enter 1 for yes or 0 for no.\n\n";
    cin>>OptionCheck;                                       //To ascertain option choice verificoration from user

    if((OptionCheck!=0)&&(OptionCheck!=1))
    {
        cout<<"The data you entered for this request is non valid.\n";
        cout<<"Go back to the menu and choose an option again\n";
        return 0;
    }

    else if(OptionCheck==0)
    {

        return 0;
    }
    else if(OptionCheck==1)
    {

        VerifyCount(CountFilled);       // Always verify count before accumulating data.

        if (CountFilled.GetCounter()==0)
        {

            cout<<"There is no information in the database to process\n";
            return 0;
        }
        else if (CountFilled.GetCounter()>0)
        {
            cout<<"please enter the sell date of the the bovines in the form ##/##/##\n";
            cout<<"whose profits you wish to calculate\n";

            cin.get(ch);
            getline(cin,Date);

            while(!container[0].CheckIfDateIsValid(Date)){                    //Outsource data validation checking to base class.
                cout<<"The data you entered is invalid. Please try again\n";
            getline(cin,Date);

                                                         }

            for(i=0; i<CountFilled.GetCounter(); i++)
            {
                if(Date==container[i].getSellDate())
                {

                    TotalCosts=(TotalCosts+container[i].getCost()+container[i].getAvCostProcess());
                    TotalRevenues=(TotalRevenues+container[i].getGrossSaleprice());
                    continue;
                }
                else if(Date!=container[i].getSellDate()){
                    continue;
                                                         }

        }
         }
    }
    if (TotalRevenues==0)
    {

        cout<<"Either the supplier name you provided is not a member of the database\n";
        cout<<"or there are no sales data entered for animals associated with that supplier\n";
        cout<<"name\n";
        cout<<"\n";
    }

    else if(TotalCosts>TotalRevenues){                       //Allow for situation where money has been lost.
         TotalLosses=(TotalCosts-TotalRevenues);
        cout<<"You have lost money on bovines which were supplied by the\n";
        cout<<"supplier name which you provided. You have lost a total of\n";
        cout<<TotalLosses;
        cout<<"\t";
        cout<<"euros\n";


                                     }


    else if (TotalRevenues>TotalCosts){
        TotalProfits=(TotalRevenues-TotalCosts);
        cout<<"The total profits for bovines associated with the supplier\n";
        cout<<"name you entered are\n";
        cout<<TotalProfits;
        cout<<"\n";
                                      }
    return 0;
}






float ProcessClass::TotalProfitInYear(Counter& CountFilled) {

char ch;
int i=0;
int OptionCheck=0;
float TotalRevenue=0;
string YearRequest;
string DatabaseYear;
int TotalCosts=0;
float TotalProfits=0;
float TotalLosses=0;

cout<<"You have selected the option to calculate total profits from\n";
cout<<"bovines within a particular year. Please verify that you wish\n";
cout<<"to proceed with this option. Enter 1 for yes or 0 for no\n";

cin>>OptionCheck;

if ((OptionCheck!=0)&&(OptionCheck!=1)){           // Allow user to verify that option chosen is intended one.

    cout<<"The data you entered is invalid. Please return to menu\n";
    return 0;
                                       }
  else if(OptionCheck==0){

    return 0;
                         }
else if (OptionCheck==1)
{

    VerifyCount(CountFilled);                    // Always verify count is correct before accumulating data.

    if(CountFilled.GetCounter()==0){             // No point in attempting to gather data if container is empty.

        cout<<"The Database is empty. Please return to menu and inform\n";
        cout<<"the administrator\n";
        return 0;
                                   }
        else if(CountFilled.GetCounter()>0)
        {

            cout<<" Plese enter the year in the form /## that\n";
            cout<<" within which you wish to calculate costs\n";


           cin.get(ch);
           getline(cin,YearRequest);

            while (!container[0].CheckIfYearIsValid(YearRequest))     // Outsource checking for valid data to base class.
            {
                cout<<"That is not a valid date or format is incorrect\n";
                cout<<"Please re-enter the date in the correct format\n";
                getline(cin,YearRequest);
            }
            for(i=0;i<CountFilled.GetCounter();i++){

                DatabaseYear=container[i].getSellDate();

                if((YearRequest[0]==DatabaseYear[5])&&(YearRequest[1]==DatabaseYear[6])&&(YearRequest[2]==DatabaseYear[7]))
                                                       {
                    TotalRevenue=(TotalRevenue+container[i].getGrossSaleprice());
                    TotalCosts=(TotalCosts+container[i].getCost()+container[i].getAvCostProcess());
                    continue;
                                                    }
                    else {

                        continue;
                         }


               }
        }
}



            if (TotalRevenue==0)
    {

        cout<<"Either the year you provided is not a member of the database\n";
        cout<<"or there are no sales data entered for animals associated with that year\n";

        cout<<"\n";
    }

    else if(TotalCosts>TotalRevenue){                // Must allow for situation where money has been lost.
         TotalLosses=(TotalCosts-TotalRevenue);
        cout<<"You have lost money on bovines which were sold in the year you provided.\n";
        cout<<"You have lost a total of\n";
        cout<<TotalLosses;
        cout<<"\t";
        cout<<"euros\n";


                                    }


    else if (TotalRevenue>TotalCosts){
        TotalProfits=(TotalRevenue-TotalCosts);
        cout<<"The total profits for bovines associated with the supplier\n";
        cout<<"name you entered are\n";
        cout<<TotalProfits;
        cout<<"\n";

                                     }
return 0;
}




int AccountingMenu(ProcessClass *Accprocessor,Counter& CountFilled);   // A second menu option is most easily implemented
int AdministratorMenu(ProcessClass *AdminProcessor,Counter& CountFilled);                                                                         // by crating a function for it/

int AccPasswordMenu(ProcessClass *Accprocessor,Counter& CountFilled);
int AdminPasswordMenu(ProcessClass *AdminProcessor,Counter& CountFilled);




int main (void)
{


    int ContainerSize=0;     // Best practice involves always ensuring variables/objects have been
                             // initialized as soon as they have been created.


//string AdminPassword="adminentryagent215";
//string FarmOwnerPassword="farmowneragent315";
//string Password;
//char ch;


    Counter Count;
    Count.SetCounter(0);



    cout<<"Please specify the size You would like the farm animal container to be.\n";   // Dynamic Memory Allocation should
    cout<<"The size should be less than the maximum allowable size of 1000 and \n";      // involve allowing user to select size of
    cout<<"greater than the number of members on file\n";                                // container so it can grow or shrink
                                                                                         // as required.


      while (!(cin>>ContainerSize))     // Must ensure valdity of data supplied.
  {
    cin.clear();
    cin.ignore(80, '\n');
    cout << "Sorry, not a number: try again\n";
  }


     if(ContainerSize>MaxSize){                                      // Should set limit on maximum size of container.
        cout<<"That is too large a container size. Please re-launch the program\n";
        cout<<"and enter an appropriate size according to the aforementioned\n";

                      return 0;
                              }

     else
     {

     ProcessClass AdminProcessor(ContainerSize);  // Declare as ProcessClass object because inheritance
                                                  // allows this object to access almost any function
                                                   // in the whole program.



  /*   cout<<"To be presented with your access permissions, please enter your Password\n\n";
     cin.get(ch);
    getline(cin,Password);

    while(!( (AdminPassword==Password)||(FarmOwnerPassword==Password )))
        {
        cout<<"Password invalid, please try again\n\n";

        getline(cin,Password);
        }

    if(Password==AdminPassword){

        AdminPasswordMenu(&AdminProcessor,Count);

    }

     else if(Password==FarmOwnerPassword)
        {
       AccPasswordMenu(&AdminProcessor,Count);
     }

*/




     AdministratorMenu(&AdminProcessor,Count);

    cout<<"\n";
    cout<<"\n";

   cout<<"\n";
    cout<<"\n";


     }
return 0;
}

int AdministratorMenu(ProcessClass *AdminProcessor,Counter& CountFilled)
{
for(;;){
int indexnumber=0;
bool exit=false;
int MenuOptionNumber=0;
FarmAnimal temp;         // Needed to pass between functions by reference.

    temp.setAnimalid();      // User defined objects should also be initialized promptly.
    temp.setCost();
    temp.setGrossSaleprice();
    temp.setSupplierName();
    temp.setBoughtDate();
    temp.setSellDate();
    temp.setAvCostProcess();
    temp.setBreed();
    temp.setSex();
    temp.setInWeight();
    temp.setOutWeight();
    temp.setRetailPricePerkg();



    cout<<"This is your main menu, please select an  option number\n\n";

    cout<<" 1.   fill container\n\n";
    cout<<" 2.   Load From File\n\n";
    cout<<" 3.   search for container member and display if found\n\n";
    cout<<" 4.   display all contents  of container\n\n";
    cout<<" 5.   create and Insert new container member\n\n";
    cout<<" 6.   delete a member from the container\n\n";
    cout<<" 7.   Amend a member of the container\n\n";
    cout<<" 8.   Verify the count of the number of members is correct\n\n";
    cout<<" 9.   Check if nearing the end of container capacity or if container is full\n\n";
    cout<<" 10.  Display a member by entering the member index number\n\n";
    cout<<" 11.  Go to Accounting Menu\n\n";
    cout<<" 12.  Save To File\n\n";
    cout<<" 13.  Print To File\n\n";
    cout<<" 14.  quit the program and exit\n\n";

    cin>>MenuOptionNumber;

  switch(MenuOptionNumber)

    {

    case 1:
        AdminProcessor->Fillcontainer(CountFilled);
        break;
    case 2:
        AdminProcessor->LoadFromFile(CountFilled);
        break;
    case 3:
        AdminProcessor->search(&temp,CountFilled);
        break;
    case 4:
        AdminProcessor->DisplayContainerMembers(CountFilled);
        break;
    case 5:
        AdminProcessor->CreateNewMember(&temp,CountFilled);
        break;
    case 6:
        AdminProcessor->DeleteMember(&temp,CountFilled);
        break;
    case 7:
        AdminProcessor->Amend(&temp,CountFilled);
        break;
    case 8:
        AdminProcessor->VerifyCount(CountFilled);
        break;
    case 9:
        AdminProcessor->IfMaxReached(CountFilled);
        break;
    case 10:
        cout<<"enter an index number\n";
        cin>>indexnumber;                         // Not recommended but a little overflow of code here in menu switch
         cout<<"AnimalID        ";cout<<"Breed       ";cout<<"Sex  ";cout<<"InWeight(kgs) ";cout<<"Cost    "; cout<<"BoughtDate  ";cout<<"SellDate  ";cout<<"AverageCostProcesses  ";cout<<"Outweight(kgs)  ";cout<<"RetailPrice/Kg  ";cout<<"GrossSalePrice  ";cout<<"SupplierName\n\n";
        AdminProcessor->DisplayMember(indexnumber);
        break;
    case 11:
          AccountingMenu(AdminProcessor,CountFilled);
          break;

   case 12:
       AdminProcessor->SaveToFile(CountFilled);
          break;
    case 13:
         AdminProcessor->PrintAsReport(CountFilled);
          break;
    case 14:
        exit=true;
        break;
    default:
        cout<<"please select again\n\n\n";

        break;
    }
    cout<<"\n\n";
    if(exit){
        break;
    }
}
return 0;
}



int AccountingMenu(ProcessClass *Accprocessor,Counter& CountFilled)
{
for(;;){

bool exit=false;
int Menu2OptionNumber=0;

cout<<"Here is your Accounting Menu, Please select an option\n\n";
cout<<" 1. Calculate total costs by supplier name\n\n";
cout<<" 2. Calculate total costs by date sold\n\n";
cout<<" 3. Calculate total costs by year sold\n\n";
cout<<" 4. Calculate total revenues by animals sold\n\n";
cout<<"    which were bought from a given supplier name\n\n";
cout<<" 5. Calculate total revenues by date sold\n\n";
cout<<" 6. Calculate total revenues by year sold\n\n";
cout<<" 7. Calculate total profits by animals sold\n\n";
cout<<"    which were bought from a given supplier name\n\n";
cout<<" 8. Calculate total profits by date sold\n\n";
cout<<" 9. Calculate total profits by year sold\n\n";
cout<<" 0. Exit this Menu\n\n";
cin>>Menu2OptionNumber;

switch(Menu2OptionNumber){

case 1:
    Accprocessor->TotalCostbySupplierName(CountFilled);
    break;

case 2:
    Accprocessor->TotalCostbyDateSold(CountFilled);
    break;
case 3:
    Accprocessor->TotalCostsInYear(CountFilled);
    break;
case 4:
    Accprocessor->TotalRevenuebySupplierName(CountFilled);
    break;
case 5:
    Accprocessor->TotalRevenuebyDateSold(CountFilled);
    break;
case 6:
    Accprocessor->TotalRevenueInYear(CountFilled);
    break;
case 7:
    Accprocessor->TotalProfitbySupplierName(CountFilled);
    break;
case 8:
    Accprocessor->TotalProfitbyDateSold(CountFilled);
    break;
case 9:
    Accprocessor->TotalProfitInYear(CountFilled);
    break;
case 0:
    exit=true;
    break;
default:
    cout<<"Please select again\n";
    break;
                    // Allow user to verify option chosen is intended one.}
}
if (exit){
    break;
}

}

return 0;
}

/*
int AccPasswordMenu(ProcessClass *Accprocessor,Counter& CountFilled)
{
for(;;){

bool exit=false;
int Menu2OptionNumber=0;

cout<<"Here is your Accounting Menu, Please select an option\n\n";
cout<<" 1. Load all data from file\n\n";
cout<<" 2. Calculate total costs by supplier name\n\n";
cout<<" 3. Calculate total costs by date sold\n\n";
cout<<" 4. Calculate total costs by year sold\n\n";
cout<<" 5. Calculate total revenues by animals sold\n\n";
cout<<"    which were bought from a given supplier name\n\n";
cout<<" 6. Calculate total revenues by date sold\n\n";
cout<<" 7. Calculate total revenues by year sold\n\n";
cout<<" 8. Calculate total profits by animals sold\n\n";
cout<<"    which were bought from a given supplier name\n\n";
cout<<" 9. Calculate total profits by date sold\n\n";
cout<<" 10. Calculate total profits by year sold\n\n";
cout<<" 0. Exit this Menu\n\n";
cin>>Menu2OptionNumber;

switch(Menu2OptionNumber){
case 1:
    Accprocessor->LoadFromFile(CountFilled);
     break;
case 2:
    Accprocessor->TotalCostbySupplierName(CountFilled);
    break;

case 3:
    Accprocessor->TotalCostbyDateSold(CountFilled);
    break;
case 4:
    Accprocessor->TotalCostsInYear(CountFilled);
    break;
case 5:
    Accprocessor->TotalRevenuebySupplierName(CountFilled);
    break;
case 6:
    Accprocessor->TotalRevenuebyDateSold(CountFilled);
    break;
case 7:
    Accprocessor->TotalRevenueInYear(CountFilled);
    break;
case 8:
    Accprocessor->TotalProfitbySupplierName(CountFilled);
    break;
case 9:
    Accprocessor->TotalProfitbyDateSold(CountFilled);
    break;
case 10:
    Accprocessor->TotalProfitInYear(CountFilled);
    break;
case 0:
    exit=true;
    break;
default:
    cout<<"Please select again\n";
    break;
                    // Allow user to verify option chosen is intended one.}
}
if (exit){
    break;
}

}
return 0;
}



int AdminPasswordMenu(ProcessClass *AdminProcessor,Counter& CountFilled)
{
for(;;){
int indexnumber=0;
bool exit=false;
int MenuOptionNumber=0;
FarmAnimal temp;         // Needed to pass between functions by reference.

    temp.setAnimalid();      // User defined objects should also be initialized promptly.
    temp.setCost();
    temp.setGrossSaleprice();
    temp.setSupplierName();
    temp.setBoughtDate();
    temp.setSellDate();
    temp.setAvCostProcess();
    temp.setBreed();
    temp.setSex();
    temp.setInWeight();
    temp.setOutWeight();
    temp.setRetailPricePerkg();



    cout<<"This is your main menu, please select an  option number\n\n";

    cout<<" 1.   fill container\n\n";
    cout<<" 2.   Load From File\n\n";
    cout<<" 3.   search for container member and display if found\n\n";
    cout<<" 4.   display all contents  of container\n\n";
    cout<<" 5.   create and Insert new container member\n\n";
    cout<<" 6.   delete a member from the container\n\n";
    cout<<" 7.   Amend a member of the container\n\n";
    cout<<" 8.   Verify the count of the number of members is correct\n\n";
    cout<<" 9.   Check if nearing the end of container capacity or if container is full\n\n";
    cout<<" 10.  Display a member by entering the member index number\n\n";
    cout<<" 11.  Save To File\n\n";
    cout<<" 12.  Print To File\n\n";
    cout<<" 13.  quit the program and exit\n\n";


    cin>>MenuOptionNumber;

  switch(MenuOptionNumber)

    {

    case 1:
        AdminProcessor->Fillcontainer(CountFilled);
        break;
    case 2:
        AdminProcessor->LoadFromFile(CountFilled);
        break;
    case 3:
        AdminProcessor->search(&temp,CountFilled);
        break;
    case 4:
        AdminProcessor->DisplayContainerMembers(CountFilled);
        break;
    case 5:
        AdminProcessor->CreateNewMember(&temp,CountFilled);
        break;
    case 6:
        AdminProcessor->DeleteMember(&temp,CountFilled);
        break;
    case 7:
        AdminProcessor->Amend(&temp,CountFilled);
        break;
    case 8:
        AdminProcessor->VerifyCount(CountFilled);
        break;
    case 9:
        AdminProcessor->IfMaxReached(CountFilled);
        break;
    case 10:
        cout<<"enter an index number\n";
        cin>>indexnumber;                         // Not recommended but a little overflow of code here in menu switch
         cout<<"AnimalID        ";cout<<"Breed       ";cout<<"Sex  ";cout<<"InWeight(kgs) ";cout<<"Cost    "; cout<<"BoughtDate  ";cout<<"SellDate  ";cout<<"AverageCostProcesses  ";cout<<"Outweight(kgs)  ";cout<<"RetailPrice/Kg  ";cout<<"GrossSalePrice  ";cout<<"SupplierName\n\n";
        AdminProcessor->DisplayMember(indexnumber);
        break;


   case 11:
       AdminProcessor->SaveToFile(CountFilled);
          break;
    case 12:
         AdminProcessor->PrintAsReport(CountFilled);
          break;
    case 13:
        exit=true;
    break;
    default:
        cout<<"please select again\n\n\n";

        break;
    }
    cout<<"\n\n";
    if(exit){
        break;
    }
}
return 0;
}
*/




