#include <iostream>
#include "classeY.h"

using namespace std;

Y::Y(long size)
{
    int i = 0;

    if (size > 0)
    {
        tmax = size;
        vals = new double[tmax];
    }
    else
    {
        tmax = 0;
        vals = NULL;
    }
    tutil = 0;

    for (i = 0; i < tmax ; i = i + 1)
    {
        vals[i] = i;
    }

    cout << "construction du tableau" << endl;
}

Y::Y(const Y& copie)
{
    int i = 0;

    tmax = copie.tmax;

    this -> vals = new double [tmax];

    for (i = 0; i < tmax; i = i + 1)
    {
        this -> vals [i] = copie.vals [i];
    }

    cout << "construction du tableau par copie" << endl;
}

Y::~Y()
{
    if (vals != NULL)
    {
        delete (vals);
        cout << "destruction du tableau" << endl;
    }
}

void Y:: print() const
{
    int i = 0;

    for (i = 0; i < tmax; i = i + 1)
    {
        cout << "tableau [" << i << "] = " << vals [i] << endl;
    }

    cout << endl;
}
