#include <iostream>
#include "wielomian.h"
using namespace std;

Wielomian::Wielomian()
{
	st=0;
	wsp=new double[1];
	*wsp=0;
}

Wielomian::Wielomian(double *w,int st)
{
	this->st=st;
	wsp=new double[st+1];
	for(int i=0; i<=st; i++)
		*(wsp+i)=*(w+i);
}

Wielomian::Wielomian(const Wielomian & w)
{
	int stopien=w.st;
	this->st=stopien;
	wsp=new double[stopien+1];
	for(int i=0; i<=stopien; i++)
		*(wsp+i)=*(w.wsp+i);
}

Wielomian  Wielomian::Pochodna(int st)
{
  /* pochodna - metoda nie zaimplementowana */
	return *this;

}

void Wielomian::Wyswietl()
{
	for(int i=st; i>0; i--)
		if(wsp[i]!=0) 
      {
         if(wsp[i]!=1.0) cout << showpos << wsp[i] << noshowpos ;
         if(i!=1) cout << " x^"  << i  << " "; else cout << " x " ;
      }
      if (wsp[0]!=0) 	cout << showpos << wsp[0] << noshowpos << endl;
}

Wielomian::~Wielomian()
{
	delete [] wsp;
}

Wielomian& Wielomian::Wczytaj()
{
   int st;
   cout << "Stopien wielomianu ?" << endl ;
   cin >> st;
   this->st=st;
   this->wsp=new double[st+1];

	for(int i=st; i>=0; i--)
   {
      cout << "a[" << i << "]= " ;
      cin >> this->wsp[i];
   }
   return *this;
}
