#ifndef HEADER1_H_INCLUDED
#define HEADER1_H_INCLUDED



#endif // HEADER1_H_INCLUDED

/************************************************************************************
 * @author William McDonnell                                                        *
 *                                                                                  *
 * This is a Farm Animal record keeping and accounts processing                     *
 * software package. The primary purpose of the Software is to provide              *
 * a practical recording, storing and financial accounting application              *
 * for individual farm animals and the collective farm herd.                        *
 * A secondary purpose of the software, is to gain practical experience             *
 * in producing a software package in C++ which has been debugged&tested            *
 * successfully, which is ready to use 'in the field' as it were. Not only          *
 * is the software ready to be launched for use in an agricultural animal           *
 * farming system it also serves the purpose of maintaining My C++ programming      *
 * skillset as well as improving proficieny with the language. It is                *
 * appropriate that the software has been designed, developed and implemented       *
 * for a real-life Farm animal recording and financial accounting system with       *
 * specific requirements. For the requirements and design of the project, please    *
 * refer to the software development link accessible from the site www.engiome.com. *     .
 *                                                                                  *
 ***********************************************************************************/




using namespace std;
class FarmAnimal         // To support instantiation of unique object for each farm animal.
{

private:

    string Animalid;     // Also used to prevent duplicate entries in container.
    int InWeight;
    int OutWeight;
    int Cost;
    int AvCostProcess;


    string Sex;
    string Breed;
    string  SupplierName;
    string  BoughtDate;

    float RetailPricePerkg;
    float GrossSaleprice;
    string  SellDate;
    int SoldFlag;         // So it can easily be determined whether sales data is present or not.

public:
    void setAnimalid(bool setby=false,string id="0");             // To ensure members are initialized and there are also
    void setInWeight(bool setby=false,int theInWeight=0);         // times when it's useful to fill members with valid but
    void setOutWeight(bool setby=false,int theOutWeight=0);       // generic data when deleting a member or for testing purposes
    void setCost(bool setby=false,int cost=0);                    // and then alternating to requesting specific data.
    void setAvCostProcess(bool setby=false,int theAvCostProcess=0);
    void setSex(bool setby=false,string theSex="unfilled");
    int setBreed( bool setby=false,string theBreed="unfilled");
    int setSupplierName(bool setby=false,string suppname="unfilled");
    void setBoughtDate(bool setby=false,string BDate="unfilled");
    void setRetailPricePerkg(bool setby=false,float theRetailPriceperkg=0);
    void setGrossSaleprice(bool setby=false,float GrossSaleprice=0);
    void setSellDate(bool setby=false,string SDate="unfilled");
    void setSoldFlag(int thesoldflag=0);

    string getAnimalid();
    int getInWeight();
    int getOutWeight();
    int getCost();
    int getAvCostProcess();
    string getSex();
    string getBreed();
    string getSupplierName();
    string getBoughtDate();

    float getRetailPricePerkg();
    float getGrossSaleprice();
    string getSellDate();
    int getSoldFlag();

    FarmAnimal& operator=(FarmAnimal& RHS);    // Overloading operators for posterity.
    bool operator==(FarmAnimal& RHS);          // Other programs maybe written utilizing this class
                                               // where it would be important to have use of these
                                               // overloaded operators.

    bool CheckIfYearIsValid(string Year);      // These functions will ensure integrity and correct format of data
    bool CheckIfStringIsValid(string name);    // before committing it to the data structure.
    bool CheckIfDateIsValid(string Date);
    bool CheckIfAnimalIdIsValid(string AnimalId);
     FarmAnimal();
    ~FarmAnimal();

};

class Counter           // Creating a dedicated class object for the counter(variable which
{                       // keeps track of inputted members as opposed to size which we will
                        // later see is used to initialize). Creating a dedicated class for
private:                // count will provide an extra layer of access protection for this variable.
    int *Count;


public:
    Counter();
    ~Counter();
    Counter(Counter& RHS);            // Copy constructor should always be included where member data
                                      // is later being defined on the free store.

    void SetCounter(int sCount);
    int  GetCounter(void);

    Counter& operator++();             // Overload these operators for ease of use of Counter object.
    Counter operator++(int theflag);
    Counter& operator--();

};


class AnimalContainer
{

public:

    AnimalContainer(int theSize);          // facilitates user to set size of container in constructor.

    AnimalContainer(AnimalContainer& RHS); // We may want to create a copy of the container before user makes
                                           // any changes to it. The option would be there to use it like an
                                           // undo button and could provide an important layer of insurance
                                           // for the user.

    virtual ~AnimalContainer();            // Destructor in base class should always be declared virtual.



    void Fillcontainer(Counter& CountFilled);    // This function has been very usefull for testing purposes

    int VerifyCount(Counter& CountFilled);       // Explicit check to ensure counter value is equal to number
                                                 // of inputted members.

    bool IfMaxReached(Counter& CountFilled);     // User should be informed if they are close to or at full capacity.
    void DisplayMember(int Offset);

    int search(FarmAnimal *temps,Counter& CountFilled);                  // Search should be overloaded to find and display a
    int search(FarmAnimal *temps,bool *ifpresent,Counter& CountFilled);  // member but also to check for presence without
    int CreateNewMember(FarmAnimal *tempc,Counter& CountFilled);         // displaying as a safeguarding mechanism to help
    int DeleteMember(FarmAnimal *tempc,Counter& Countfilled);            // in preventing duplicate entries. Can be called
                                                                         // from create.

    int Amend(FarmAnimal* tempc,Counter& CountFilled);
    void InsertNewMember(FarmAnimal *temps,Counter& CountFilled);
    int DisplayContainerMembers(Counter& CountFilled);


    FarmAnimal& operator[](int offset)
    {
        return container[offset];          // Declare a function inline where appropriate.
    }
    AnimalContainer& operator=(AnimalContainer& RHS);


protected:

    FarmAnimal *container;       // Intended to use as pointer to array of objects on the freestore
    int Size;                    // representing a database of records. User selects the size so
                                 // strucure can grow or shrink as required. This represents the DMA.
};


class Fileprocesses: public AnimalContainer   // Seperate class for file support inherited from container class
{                                             // so as to have access to container structure.




public:
    Fileprocesses(int Size);                 // Size of container must percolate upwards to base class.
    ~Fileprocesses();

    int LoadFromFile(Counter& CountFilled);  // All information added to structure must be saved for later access
    int SaveToFile(Counter& CountFilled);    // via the load function.

    int PrintAsReport(Counter& CountFilled); // Making use of a second and seperate file so as structure
};                                           // Data can be printed as a presentable report.

class ProcessClass: public Fileprocesses
{

public:
    ProcessClass(int Size);                  // Struccture size selected by user percolates upwards to container class.
    ~ProcessClass();

    int TotalCostbySupplierName(Counter& CountFilled);    // We want varied set of options for accounting.
    int TotalCostbyDateSold(Counter& CountFilled);
    int TotalCostsInYear(Counter& CountFilled);

    float TotalRevenuebySupplierName(Counter& CountFilled);
    float TotalRevenuebyDateSold(Counter& CountFilled);
    float TotalRevenueInYear(Counter& CountFilled);

    float TotalProfitbySupplierName(Counter& CountFilled);
    float TotalProfitbyDateSold(Counter& CountFilled);
    float TotalProfitInYear(Counter& CountFilled);



    };

