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;
}