/* stripe.cpp - Implementation of Stripe class
 */

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


// Constructor with default number of rows
Stripe::Stripe()
{
	const int defrows = 5;
	cursor = 0;
	nrows = defrows;
	base = new string[nrows];
}

// Constructor with size rows
Stripe::Stripe(unsigned int size)
{
	cursor = 0;
	nrows = size;
	base = new string[nrows];

}

// Destructor
Stripe::~Stripe()
{
	delete [] base;
}

// Accessor to nrows
int Stripe::numberOfRows()
{
	return nrows;
}

 
// Concatenate s to the current row and advance to next row
void Stripe::append(const char *s)
{
	base[cursor] += s;
	cursor = (cursor + 1) % nrows;
}


// Print out content
void Stripe::printout()
{
	for (int row = 0; row < nrows; ++row)
		cout << base[row] << endl;
}


// Empty out and reset content
void Stripe::reset()
{
	cursor = 0;
	for (int row = 0; row < nrows; ++row)
		base[row] = "";
}


