Hey guys, I am working on creating a dynamic queue and I am having some problems. I got my code wrote to set up the actual code but I am unsure how to put my information in and print it. I need to enter the following information in my queue and print it.

"Red Skateboard", 50, 85
"Green Skateboard", 45, 77
"Blue Skateboard", 35, 76
"Silver Skateboard", 44, 80
"Gold Skateboard", 35, 70

Here is my code can someone please show me what I need to do!

#include <iostream>
#include <fstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

//Inventory Class
class Inventory 
{
private:
	class QueueNode
	{
		friend class Inventory;
		string word;
		double value;
		double valueTwo;
		QueueNode *next;

		//Constructor
		QueueNode(string word1, double value1, double value2, QueueNode *next1 = NULL)
		{
			word = word1;
			value = value1;
			valueTwo = value2;
			next = next1;
		}
	};
	QueueNode *front;
	QueueNode *rear;

	string description;
	double PurchasePrice;
	double SalePrice;

public:
	Inventory();
	~Inventory();

	void enqueue(string, double, double);
	void dequeue(string &, double &, double &);
	bool isEmpty();
	void clear();
	

	void New_inventory (string a, double b, double c)
	{description = a; PurchasePrice = b; SalePrice = c;}
	
	//mutator and accessor functions
	Inventory (string, double, double);
	void setDescription(string);
	void setPurchasePrice(double);
	void setSalePrice(double);

	string getDescription();
	double getPurchasePrice();
	double getSalePrice();

	void interest_details();
};


Inventory::Inventory(string description, double PurchasePrice, double SalePrice)
{
//this pointers to current class
	this->description = description;
	this->PurchasePrice = PurchasePrice;
	this->SalePrice = SalePrice;

}

void Inventory::setDescription(string description)	{
	Inventory::description = description;
}

void Inventory::setPurchasePrice(double PurchasePrice)	{
	Inventory::PurchasePrice = PurchasePrice;
}

void Inventory::setSalePrice(double SalePrice)	{
	Inventory::SalePrice = SalePrice;
}

string Inventory::getDescription() {
	return description;
}

double Inventory::getPurchasePrice() {
	return PurchasePrice;
}

double Inventory::getSalePrice() {
	return SalePrice;

}

void Inventory::interest_details() {
	cout << "The current product it a " << description <<
		", the purchase price is " << PurchasePrice <<
		", anda sale price of " << SalePrice << ".\n";
}
#include "Inventory.h"
using namespace std;

Inventory::Inventory()
{
	front = NULL;
	rear = NULL;
}

Inventory::Inventory()
{
	clear();
}

void Inventory::enqueue(string description, double PurchasePrice, double SalePrice)
{
	if (isEmpty())
	{
		front = new QueueNode(description, PurchasePrice, SalePrice);
		rear = front;
	}
	else
	{
		rear->next = new QueueNode(description, PurchasePrice, SalePrice);
			rear = rear->next;
	}
}

void Inventory::dequeue(string &description, double &PurchasePrice, double &SalePrice)
{
	QueueNode *temp;
	if (isEmpty())
	{
		cout << "The queue is empty.\n";
		exit(1);
	}
	else
	{
		description = front->word;
		PurchasePrice = front->value;
		SalePrice = front->valueTwo;
		temp = front;
		front = front->next;
		delete temp;
	}
}

bool Inventory::isEmpty()
{
	if (front ==NULL)
		return true;
	else
		return false;
}

void Inventory::clear()
{
	string word,
	double value;
	double valueTwo;

	while(!isEmpty())
		dequeue(word, value, valueTwo);
}

int main() {

	Inventory iQueue;

	cout << "Enqueuing 5 items...\n";
	
	

	return 0;
}

This is what I have so far, am I completely wrong??

#include "Inventory.h"
using namespace std;

Inventory::Inventory()
{
	front = NULL;
	rear = NULL;
}

Inventory::Inventory()
{
	clear();
}

void Inventory::enqueue(string description, double PurchasePrice, double SalePrice)
{
	if (isEmpty())
	{
		front = new QueueNode(description, PurchasePrice, SalePrice);
		rear = front;
	}
	else
	{
		rear->next = new QueueNode(description, PurchasePrice, SalePrice);
			rear = rear->next;
	}
}

void Inventory::dequeue(string &description, double &PurchasePrice, double &SalePrice)
{
	QueueNode *temp;
	if (isEmpty())
	{
		cout << "The queue is empty.\n";
		exit(1);
	}
	else
	{
		description = front->word;
		PurchasePrice = front->value;
		SalePrice = front->valueTwo;
		temp = front;
		front = front->next;
		delete temp;
	}
}

bool Inventory::isEmpty()
{
	if (front ==NULL)
		return true;
	else
		return false;
}

void Inventory::clear()
{
	string word;
	double value;
	double valueTwo;

	while(!isEmpty())
		dequeue(word, value, valueTwo);
}

int main() {

	Inventory iQueue;

	string catchWord;
	double catchVal;
	double catchVal2;

	cout << "Enqueuing 5 items...\n";

	cout << "Enqueuing First Item...\n";
	iQueue.enqueue("Red Skateboard", 50, 85);
	cout << "Enqueuing Second Item...\n";
	iQueue.enqueue("Green Skateboard", 45, 77);
	cout << "Enqueuing Third Item...\n";
	iQueue.enqueue("Blue Skateboard", 35, 76);
	cout << "Enqueuing Fourth Item...\n";
	iQueue.enqueue("Silver Skateboard", 44, 80);
	cout << "Enqueuing Fifth Item...\n";
	iQueue.enqueue("Gold Skateboard", 35, 70);

	cout << "Dequeueing 5 items...\n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";



	

	return 0;
}

Never mind guys I got my code to work!

#include "Inventory.h"
using namespace std;

Inventory::Inventory()
{
	front = NULL;
	rear = NULL;
}

Inventory::~Inventory()
{
	clear();
}

void Inventory::enqueue(string description, double PurchasePrice, double SalePrice)
{
	if (isEmpty())
	{
		front = new QueueNode(description, PurchasePrice, SalePrice);
		rear = front;
	}
	else
	{
		rear->next = new QueueNode(description, PurchasePrice, SalePrice);
			rear = rear->next;
	}
}

void Inventory::dequeue(string &description, double &PurchasePrice, double &SalePrice)
{
	QueueNode *temp;
	if (isEmpty())
	{
		cout << "The queue is empty.\n";
		exit(1);
	}
	else
	{
		description = front->word;
		PurchasePrice = front->value;
		SalePrice = front->valueTwo;
		temp = front;
		front = front->next;
		delete temp;
	}
}

bool Inventory::isEmpty()
{
	if (front ==NULL)
		return true;
	else
		return false;
}

void Inventory::clear()
{
	string word;
	double value;
	double valueTwo;

	while(!isEmpty())
		dequeue(word, value, valueTwo);
}

int main() {

	Inventory iQueue;

	string catchWord;
	double catchVal;
	double catchVal2;

	cout << "Enqueuing 5 items...\n";

	cout << "Enqueuing First Item...\n";
	iQueue.enqueue("Red Skateboard", 50, 85);
	cout << "Enqueuing Second Item...\n";
	iQueue.enqueue("Green Skateboard", 45, 77);
	cout << "Enqueuing Third Item...\n";
	iQueue.enqueue("Blue Skateboard", 35, 76);
	cout << "Enqueuing Fourth Item...\n";
	iQueue.enqueue("Silver Skateboard", 44, 80);
	cout << "Enqueuing Fifth Item...\n";
	iQueue.enqueue("Gold Skateboard", 35, 70);

	cout << "\nDequeueing 5 items...\n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

		//Delete One from Inventory
	cout << "\nDelete the Red Skateboard \n";
	cout << "_____________________________________________________________ \n";
	
	cout << "Enqueuing 4 items...\n";

	cout << "Enqueuing First Item...\n";
	iQueue.enqueue("Green Skateboard", 45, 77);
	cout << "Enqueuing Second Item...\n";
	iQueue.enqueue("Blue Skateboard", 35, 76);
	cout << "Enqueuing Third Item...\n";
	iQueue.enqueue("Silver Skateboard", 44, 80);
	cout << "Enqueuing Fourth Item...\n";
	iQueue.enqueue("Gold Skateboard", 35, 70);
	
	cout << "\nDequeueing 4 items...\n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	//Add 2 More Items
	cout << "\nAdding 2 new items \n";
	cout << "_____________________________________________________________ \n";
	
	cout << "Enqueuing First Item...\n";
	iQueue.enqueue("Green Skateboard", 45, 77);
	cout << "Enqueuing Second Item...\n";
	iQueue.enqueue("Blue Skateboard", 35, 76);
	cout << "Enqueuing Third Item...\n";
	iQueue.enqueue("Silver Skateboard", 44, 80);
	cout << "Enqueuing Fourth Item...\n";
	iQueue.enqueue("Gold Skateboard", 35, 70);
	cout << "Enqueuing Fifth Item...\n";
	iQueue.enqueue("Orange Skateboard", 50, 72);
	cout << "Enqueuing Sixth Item...\n";
	iQueue.enqueue("Purple Skateboard", 45, 82);

	cout << "\nDequeueing 6 items...\n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";
	
	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	iQueue.dequeue(catchWord, catchVal, catchVal2); 
	cout << "The current product is a " << catchWord << ", the purchase price is $" << catchVal << ", and a sale price of $" << catchVal2 << ". \n";

	return 0;
}
This article has been dead for over six months. Start a new discussion instead.