#include <iostream>
#include <math.h>

#define TYPE 4


#if TYPE==1
int kwadraat(int getal)
{
  return getal * getal;
}
#endif


#if TYPE==2
void wortel(int getal, double *wortel_1, double *wortel_2)
{
  getal = 49; // wat doet dit met getal in de main functie?
  *wortel_1 = sqrt(getal);
  *wortel_2 = -*wortel_1;
}
#endif


#if TYPE==3
void calculate_sine(float * buffer, long nrofsamples)
{
  for(long x=0; x<nrofsamples; x++)
  {
    buffer[x] = sin((double)x/nrofsamples * 2 * M_PI);
  }
}
#endif


#if TYPE==4
struct Sneeuwpop
{
float buikomtrek;
float hoofdomtrek;
int aantalarmen;
bool wortelneus;
};


void maak_sneeuwpop(void *eigenschappen)
{
  Sneeuwpop *props_pointer = (Sneeuwpop *) eigenschappen;

  float buik=props_pointer->buikomtrek;
  float hoofd=props_pointer->hoofdomtrek;
  int armen=props_pointer->aantalarmen;
  bool neus=props_pointer->wortelneus;

  std::cout << "*********************" << std::endl;
  std::cout << "***** Sneeuwpop *****" << std::endl;
  std::cout << "*********************" << std::endl;
  std::cout << "Buikomtrek: " << buik << " meter" << std::endl;
  std::cout << "Hoofdomtrek: " << hoofd << " meter" << std::endl;
  std::cout << armen << " armen en ";
  std::cout << (neus ? "een wortelneus" : "geen neus") << std::endl;

  // change one of the props
  // props_pointer->buikomtrek = 500;
}
#endif

int main()
{

#if TYPE==1
  /*
   * Functie die 1 parameter teruggeeft
   */
  int getal = 5;
  std::cout << getal << " kwadraat = " << kwadraat(getal) << std::endl;
#endif

#if TYPE==2
  /*
   * Functie die 2 parameters teruggeeft
   */
  int getal=25;
  double wortel_a,wortel_b;

  wortel(getal, &wortel_a, &wortel_b);
  std::cout << "Getal " << getal << std::endl;
  std::cout << "Eerste wortel uit " << getal << " = " << wortel_a << std::endl;
  std::cout << "Tweede wortel uit " << getal << " = " << wortel_b << std::endl;
#endif


#if TYPE==3
  /*
   * Functie die een array met waarden vult
   */
  float buffer[256];
  calculate_sine(buffer,256);

  for(long sample=0; sample<256; sample++)
    std::cout << buffer[sample] << std::endl;
#endif


#if TYPE==4
  /*
   *
   */
  Sneeuwpop pop_eigenschappen;
  pop_eigenschappen.buikomtrek=2.5;
  pop_eigenschappen.hoofdomtrek=0.95;
  pop_eigenschappen.aantalarmen=5;
  pop_eigenschappen.wortelneus=false;
  maak_sneeuwpop((void *) &pop_eigenschappen);
#endif

} // main()

