// Bonsai.h
// Object Model Demonstration using Bonsai. A bonsai is a non-empty set of trees
// in a bonsai pot. The term "bonsai" is both singular and plural.
// Version 1.12.
// Copyright 1999 by Rick Wagner, all rights reserved. Authorized use with
// attribution for educational purposes only.
// Created September 25, 1999.
// Last edited November 5, 1999.

#ifndef BONSAI_H
#define BONSAI_H

#include <iostream.h>
#include <string.h>

const int giMaxTrees = 1000;
const int giMaxPots = 1000;
const int giMaxBonsai = 1000;
const int giMaxNameLength = 100;

class Bonsai;                                           // Predefine a class for reference.

// Class for the living organism that is a part of bonsai:
class Tree
{
public:
  Tree(const char* name = "", const char* species = "", // Default and parameter constructor.
       Bonsai* partOf = NULL);
  ~Tree();                                              // Destructor.

  char* getName() const;                                // Accessors.
  char* getSpecies() const;
  Bonsai* getPartOf() const;                            // Defined in class head above.

  void setName(char* name);                             // Mutators.
  void setSpecies(char* species);
  void setPartOf(Bonsai* bonsai);

private:
  char* _name;
  char* _species;
  Bonsai* _partOf;                                       // Defined in class head above.
};

// Class for the inanimate object that is a part of bonsai:
class Pot
{
public:
  Pot(float size = 0, const char* style = "", const char* color = "",
      const char* country = "", Bonsai* partOf = NULL);  // Default and parameter constructor.
  ~Pot();                                                // Destructor.

  float getSize() const;                                 // Accessors.
  char* getStyle() const;
  char* getColor() const;
  char* getCountry() const;
  Bonsai* getPartOf() const;                             // Defined in class head above.

  void setSize(float size);                              //Mutators.
  void setStyle(char* style);
  void setColor(char* color);
  void setCountry(char* country);
  void setPartOf(Bonsai* bonsai);

private:
  float _size;
  char* _style;
  char* _color;
  char* _countryOfOrigin;
  Bonsai* _partOf;                                        // Defined in class head above.
};

// Container class for an assembly consisting of a pot and a set of trees:
class Bonsai
{
public:
  Bonsai(const char* label = "");                       // Default constructor.
  ~Bonsai();                                            // Destructor.

  char* getLabel() const;                               // Accessors.
  Pot* getPot() const;
  int getNumTrees() const;
  Tree* getTree(int i) const;

  void setPot(Pot* pot);                                //Mutators.
  void addTree(Tree* tree);
  void removeTree(Tree* tree);

private:
  char* _label;                                         // Label for the bonsai.
  Pot* _pot;                                            // Pointer to some bonsai pot.
  int _numTrees;                                        // Number of trees in the bonsai.
  Tree** _tree;                                         // Pointer to an array of tree pointers.
};

// Class to contain the application objects:
class Collection
{
public:
  Collection();
  ~Collection();

  int getNumTrees() const;
  Tree* getTree(int i) const;

  int getNumPots() const;
  Pot* getPot(int i) const;

  int getNumBonsai() const;
  Bonsai* getBonsai(int i) const;

  void addTree(Tree* b);
  void addPot(Pot* b);
  void addBonsai(Bonsai* b);

private:
  int _numTrees;
  Tree** _tree;

  int _numPots;
  Pot** _pot;

  int _numBonsai;
  Bonsai** _bonsai;
};

#endif