5 Replies - 411 Views - Last Post: 03 August 2014 - 07:28 PM Rate Topic: -----

#1 rookie#9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 04-August 13

hash table and queue issues

Posted 02 August 2014 - 04:06 PM

here is the assignment

Horacious Glump (70 points)

Grading Rubric Points
Hashing Function 14
FIFO Queue ADT 21
Test Driver 14
Lab Write-Up 7
Lab Questions 7
Code Style 7
TOTAL 70

Deliverables
Create a single zip file including the following.

- Your Visual Studio Project directory and associated files, including source files for the iLab
- The results of your testing. What tests did you run? Did everything work okay? Are there outstanding issues in your program? A short half-page summary of your results is about the right length.
- Your answers to the Part 4 iLab questions


If you document any issues, it will be easier to isolate any problems, provide detailed help, and could potentially improve your grade.

Summary
It is the year 2025 and the new children’s literary masterpiece, Horacious Glump has been a huge entertainment success. You have been contracted to help create the new Horacious Glump theme park ride for a very popular theme park in Florida. You have devised an ingenious new system for park visitors to visit the new ride. In this iLab, you will design a proof of concept system to demonstrate the ingenuity.
Understanding the System

This iLab requires a bit of custom hybrid implementation: taking concepts from the textbook and implementing them but with some modification. Be sure to allocate sufficient time to complete the lab.

The new system envisioned is as follows.

• Park visitors will register at a kiosk if they want to ride the new theme park ride.
• Visitors will give their full names.
• The Horacious Glump system will hash their names to a particular ride number.
• Visitors will then be placed in the queue for the ride number.
• At each time interval, all rides will run simultaneously.
• At the end of the ride, the first person in each ride queue will be removed.
• There will be seven rides in the system for the prototype.
• Each ride queue holds a maximum of three people for testing.
Part 1: Mapping Names

The first part of the new ride system involves mapping names to ride numbers. To accomplish this, you will use a hash function to convert a string into a numerical value.

Recall that great time and care must be taken to choose a good hashing function; however, because this is merely a prototype system, you may use the simple hash function given below.



1) Implement the hash function within your Horacious Glump ride class.
2) Create a test driver that asks for a name from the user and outputs the ride number that it maps to.

Consider the hashValue %= hashSize line of the hash function. What is the purpose of this line? What would happen if it were removed?

Note: You do not need to submit this test driver function. It is merely for you to verify Part 1 functionality before moving on.
Part 2: Creating a Queue

A queuing system will be needed to complete the implementation. Using the ADT described in the textbook, implement a FIFO queue that holds strings. For the purposes of this activity, the maximum queue size should be 3.

You will need to implement one additional operation in your queue to support your test driver: a display function.

Note: You cannot use already existing stack and queue operations or include files. You must implement the ADT using basic data structures (arrays or linked lists). You may, however, use your ADT list that you created earlier in the course to help you. However, your insert and delete queue operations should be O(1), so you may need to modify your list ADT.


Important: Be careful with edge or border cases. For example, what happens when you remove an item and no items are present? What happens if an item is added to a queue that already has the maximum elements? Your program should not break in these conditions!
Part 3: Implementing a Test Driver

Step 1) Initialize the System

Create a test driver with a main function. This driver should automatically set up the system initialization as follows.

• Create a new hash table of size 7 for the seven rides.
• Create a new queue in each of the seven hash table positions.
• Each queue should have a maximum size of 3.

Step 2) Basic Test Commands

Create a test driver menu system similar to those for the Week 1 and Week 2 iLabs. You are welcome to implement any test commands to help you verify your queue and hash table system. In addition to any of these, you are required to have the following commands.

• Add Person
o Prompts for person’s name
o Hashes his or her name to a queue #
o Inserts the person into the queue
o Prints a confirmation to the user
o Be sure to output a message if the queue is full.
• Run System
o Prints a confirmation to the user (“Ride Running…..”)
o Removes the first person in the queue from each queue
o Displays the name of each rider and his or her queue #
o Be sure to output a message if a queue is empty.
• Find Length of Wait
o Prompts for a person’s name
o Hashes the name to a queue #
o Outputs the current size of the queue this person would be placed in
• Display System
o Outputs all seven queues in the system and—for each queue—the exact order that each person is within the queue
o A simple format is sufficient, such as the example below.

Queue #0
- Marty Smith
Queue #1
- Frank Jacobson
- Roy Laop
- Tony Ramno
Queue #2
<empty>
Queue #3
<empty>
Queue #4
- Julie Frank
- Bob Goldson

etc…
Part 4: iLab Questions

Consider and answer the following questions in brief in your iLab write-up.

1) Consider the last line of the hash function from Part 1. What is the purpose of this line?
2) What would happen if it were removed?
3) Assuming it was possible to add a very large number of rides (increase the hash table size higher than the number of visitors to the park) what would be the average big O runtime complexity of adding a person to the system?
4) In the large rides condition of question 3, what is the average big O runtime of finding the wait time for a person?
5) In actuality, all rides are run in parallel rather than one ride at a time (despite the opposite being true in your simulator because you have to loop over each queue in the run command). On a parallel system, what is the big O runtime of the run system command in the large rides condition of question 3?

General iLab Comments

All coding assignments for this class will use Microsoft Visual Studio. This is available through the Software Store, which can be found in Course Home. Contact the Help Desk if you encounter any issues or contact your professor.

*Please note as a reminder that you may not copy code from any web reference to complete this assignment, even if you correctly give credit. You may, of course, use web references to help you understand, but you must code the assignment yourself. You may use code directly from your textbook where applicable, but make sure you give credit in your comments if you are doing so.


here is my code


header
#include <iostream>
#include <string>
#include <string.h>
#include <conio.h>

class Glump
{
public:
	Glump(string *_name);
	~Glump();

private:
	string name;
	string *name = new string;
	int ID_num;
	static int ID;
};

class Node
{
public:
	Node(Glump *_H, Node *_Next);
	~Node();
	
private:
	Glump *H;
	Node *Next;
};

class Queue
{
public:
	Queue();
	~Queue();
	void Make_Empty(); // resets all values to 0 or -1
	bool is_full() const; // check if queque is full
	bool is_empty() const; // check if queue is empty
	void Enqueue(const string& value);// adds to queue
	void Dequeue(const string& value); // removes from queue
	void Hash(const string& value); // hash table function
	void Display(string, int); // display queue
	void Line_Wait_Time(); // calculates wait time for lines and sets time for simultanious rides

private:
	const int Peeps_Limit = 3; // limit of people per que
	const int Carts_Num = 7; // number of carts in ride
	int HashValue = 0;
	int HashSize = 7;
	int Max = Peeps_Limit + 1;
	int front = Max - 1;
	int rear = Max - 1;
	int que;
	string* queue;
	int StringLength;
	

};



.cpp file


#include "Horacious_Glump.h"
#include <string>
#include <string.h>

using namespace std;

Glump::Glump(string *_name)
{
	ID = 0;
	int Size = 1;

	for (int i = 0; i <= 21; i++)
	{
		if (_name = '\0')

			break;
		Size++;
	}

	name = new string[Size];

	name = _name;

	ID_num = ID++;
}

Glump::~Glump()
{
	delete[] name;
}

Node::Node(Glump *_H, Node *_Next)
{
	H = _H;
	Next = _Next;
}

Node::~Node()
{
	delete[] H;
	delete[] Next;
}

/*Queue::Queue()
{

}

Queue::~Queue()
{
	delete[] queue;
}*/

void Queue::Make_Empty()
{
	int HashValue = NULL;
	int HashSize = NULL;
	int Max = NULL;
	int front = NULL;
	int rear = NULL;
	int que = NULL;
	string* queue = NULL;
	int StringLength = NULL;

}

bool Queue::is_empty() const
{
	return (front == rear);
}

bool Queue::is_full() const
{
	return ((rear + 1) % Peeps_Limit == front);
}


void Queue::Enqueue(const string& value)
{
	if (is_full)
	{
		cout << "queue is full, please wait " << endl;
		return;
	}
	else
	{
		rear = (rear + 1) % Max;
		queue[rear] = value;
	}
}

void Queue::Dequeue(const string& value)
{
	if (is_empty)
	{
		cout << "queue is empty, select another slot" << endl;
	}
	else
	{
		front = (front + 1) % Max;
		queue[front] = value;
	}
}

void Queue::Hash(const string& value)
{
	StringLength = value.length;
	
	for (unsigned int index = 0; index < StringLength; index++)
	{
		HashValue = (HashValue * 31) + value[index];
		HashValue %= HashSize;
	}
}

void Queue::Line_Wait_Time()
{

}

void Queue::Display(string name, int Name_num)
{

	for (int i = 1; i < Name_num; i++)
	{
		cout << endl << "enter name " << i << " :";
		cin >> name;
		cout << endl << name << " is now in queue.";
	}
}



main.cpp
//not yet implemented



here are the errors

>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(9): error C2061: syntax error : identifier 'string'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(13): error C2146: syntax error : missing ';' before identifier 'name'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2143: syntax error : missing ';' before '*'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2143: syntax error : missing ';' before '='
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2238: unexpected token(s) preceding ';'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(38): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(39): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(40): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(41): error C2061: syntax error : identifier 'string'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(53): error C2143: syntax error : missing ';' before '*'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(53): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\main.cpp(14): error C2065: 'Name_num' : undeclared identifier
1> Horacious_Glump.cpp
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(9): error C2061: syntax error : identifier 'string'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(13): error C2146: syntax error : missing ';' before identifier 'name'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2143: syntax error : missing ';' before '*'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2143: syntax error : missing ';' before '='
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(14): error C2238: unexpected token(s) preceding ';'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(38): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(39): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(40): error C2143: syntax error : missing ',' before '&'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(41): error C2061: syntax error : identifier 'string'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(53): error C2143: syntax error : missing ';' before '*'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(53): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(8): error C2511: 'Glump::Glump(std::string *)' : overloaded member function not found in 'Glump'
1> c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(7) : see declaration of 'Glump'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(20): error C2065: 'name' : undeclared identifier
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(22): error C2065: 'name' : undeclared identifier
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(24): error C2597: illegal reference to non-static member 'Glump::ID_num'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(29): error C2065: 'name' : undeclared identifier
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(29): error C2541: 'delete' : cannot delete objects that are not pointers
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(79): error C2511: 'void Queue::Enqueue(const std::string &)' : overloaded member function not found in 'Queue'
1> c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.h(31) : see declaration of 'Queue'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(80): error C3867: 'Queue::is_full': function call missing argument list; use '&Queue::is_full' to create a pointer to member
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(87): error C2597: illegal reference to non-static member 'Queue::rear'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(87): error C3867: 'Queue::rear': function call missing argument list; use '&Queue::rear' to create a pointer to member
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(87): error C2597: illegal reference to non-static member 'Queue::Max'
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(87): error C3867: 'Queue::Max': function call missing argument list; use '&Queue::Max' to create a pointer to member
1>c:\users\monta_000\desktop\devry university\gsp\gsp295\week4\mbrabec_295_w4_lab\mbrabec_295_w4_lab\horacious_glump.cpp(87): error C2568: '%' : unable to resolve function overload
1> unable to recover from previous error(s); stopping compilation
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
i dont understand these errors and why i am getting them granted some of my methods are missing code.. i have not finished them yet.. im just curious about the finished ones and why i am getting these errors... any help would be greatly appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: hash table and queue issues

#2 rookie#9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 04-August 13

Re: hash table and queue issues

Posted 02 August 2014 - 07:24 PM

ok most of the errors are fixed now

new code

header
#include <iostream>
#include <string>
#include <string.h>
#include <conio.h>
using namespace std;

class Glump
{
public:
	Glump(string *_name);
	~Glump();

private:
	string name;
	int ID_num;
	static int ID;
};

class Node
{
public:
	Node(Glump *_H, Node *_Next);
	~Node();
	
private:
	Glump *H;
	Node *Next;
};

class Queue
{
public:
	Queue();
	~Queue();
	void Make_Empty(); // resets all values to 0 or -1
	bool is_full() const; // check if queque is full
	bool is_empty() const; // check if queue is empty
	void Enqueue(const string& value);// adds to queue
	void Dequeue(const string& value); // removes from queue
	void Hash(const string& value); // hash table function
	void Display(string, int); // display queue
	void Line_Wait_Time(); // calculates wait time for lines and sets time for simultanious rides

private:
	static const int Peeps_Limit = 3;// limit of people per que
	static const int Carts_Num = 7; // number of carts in ride
	int HashValue;
	int HashSize;
	int Max;
	int front;
	int rear;
	string* queue;
	int StringLength;
	string rides[Carts_Num][Peeps_Limit];
	

};



.cpp
#include "Horacious_Glump.h"
#include <string>
#include <string.h>

using namespace std;

Glump::Glump(string *_name)
{
	ID = 0;
	int Size = 1;

	for (int i = 0; i <= 21; i++)
	{
		if (_name = '\0')

			break;
		Size++;
	}

	string *name = new string;
	name = new string[Size];

	name = _name;

	ID_num = ID++;
}

Glump::~Glump()
{
	delete[] name;
}

Node::Node(Glump *_H, Node *_Next)
{
	H = _H;
	Next = _Next;
}

Node::~Node()
{
	delete[] H;
	delete[] Next;
}

Queue::Queue()
{
	int HashValue = 0;
	int HashSize = 7;
	int Max = Peeps_Limit + 1;
	int front = Max - 1;
	int rear = Max - 1;
	string* queue = new string[Peeps_Limit];
	int StringLength = 0;
	string rides[Carts_Num][Peeps_Limit];


}

Queue::~Queue()
{
	delete[] queue;
}

void Queue::Make_Empty()
{
	int HashValue = NULL;
	int HashSize = NULL;
	int Max = NULL;
	int front = NULL;
	int rear = NULL;
	string* queue = NULL;
	int StringLength = NULL;

}

bool Queue::is_empty() const
{
	return (front == rear);
}

bool Queue::is_full() const
{
	return ((rear + 1) % Peeps_Limit == front);
}


void Queue::Enqueue(const string& value)
{
	if (is_full)
	{
		cout << "queue is full, please wait " << endl;
		return;
	}
	else
	{
		rear = (rear + 1) % Max;
		queue[rear] = value;
	}
}

void Queue::Dequeue(const string& value)
{
	if (is_empty)
	{
		cout << "queue is empty, select another slot" << endl;
	}
	else
	{
		front = (front + 1) % Max;
		queue[front] = value;
	}
}

void Queue::Hash(const string& value)
{
  	StringLength = value.length;
	
	for (unsigned int index = 0; index < StringLength; index++)
	{
		HashValue = (HashValue * 31) + value[index];
		HashValue %= HashSize;
	}
}

void Queue::Line_Wait_Time()
{

}

void Queue::Display(string name, int Name_num)
{
	cout << "enter the number of names : ";
	cin >> Name_num;

	for (int i = 1; i < Name_num; i++)
	{
		cout << endl << "enter name " << i << " :";
		cin >> name;
		Enqueue(name);
		Hash(name);
		cout << endl << name << " is now in queue.";
	}
}



new errors

error C2440: 'delete' : cannot convert from 'std::string' to 'void*'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

error C3867: 'Queue::is_full': function call missing argument list; use '&Queue::is_full' to create a pointer to member

error C3867: 'Queue::is_empty': function call missing argument list; use '&Queue::is_empty' to create a pointer to member


error C3867: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::length': function call missing argument list; use '&std::basic_string<char,std::char_traits<char>,std::allocator<char>>::length' to create a pointer to member


error C2440: '=' : cannot convert from 'unsigned int (__thiscall std::basic_string<char,std::char_traits<char>,std::allocator<char>>::* )(void) throw() const' to 'int'
1> There is no context in which this conversion is possible

warning C4018: '<' : signed/unsigned mismatch


any ideas???

also if anyone can point me in the right direction for my
void Queue::Line_Wait_Time()
{

}



and

void Queue::Display(string name, int Name_num)
{
	cout << "enter the number of names : ";
	cin >> Name_num;

	for (int i = 1; i < Name_num; i++)
	{
		cout << endl << "enter name " << i << " :";
		cin >> name;
		Enqueue(name);
		Hash(name);
		cout << endl << name << " is now in queue.";
	}
}



i have a feeling that my display isnt going to do what i want it to do
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3574
  • View blog
  • Posts: 11,115
  • Joined: 05-May 12

Re: hash table and queue issues

Posted 02 August 2014 - 09:12 PM

View Postrookie#9, on 02 August 2014 - 10:24 PM, said:

new errors
Spoiler


any ideas???

The error messages are pretty self explanatory. Just take time to examine the line(s) they are referring to, and slowly read the error message. Part of learning to program in C++ is learning how to parse error messages.

View Postrookie#9, on 02 August 2014 - 10:24 PM, said:

also if anyone can point me in the right direction for my
void Queue::Line_Wait_Time()
{

}


What have your tried? Do you even have an outline of how you would do this? If you didn't have a computer, but just had drawings on paper or on a whiteboard, how would you go about doing this task?

View Postrookie#9, on 02 August 2014 - 10:24 PM, said:

Spoiler

i have a feeling that my display isnt going to do what i want it to do

What do you want it to do?
Was This Post Helpful? 0
  • +
  • -

#4 rookie#9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 04-August 13

Re: hash table and queue issues

Posted 03 August 2014 - 02:24 PM

ok the wait time line is not needed from what a classmate tells me... and the display i got figured out

void Queue::Display()
{
	for (int i = 0; i <Carts_Num; i++)
		for (int j = 0; j < Peeps_Limit; j++)
			cout << "Ride " << i << "Person: " << rides[i][j] << endl;
}



and the errors are taken care of now... except now i have a new error... i added () to the is_full, is_empy and length calls.. that took care of that now i have this

error LNK2001: unresolved external symbol "private: static int Glump::ID" (?ID@Glump@@0HA)
Was This Post Helpful? 0
  • +
  • -

#5 rookie#9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 04-August 13

Re: hash table and queue issues

Posted 03 August 2014 - 03:52 PM

ok everything is taken care of let me post the code again

header
#include <iostream>
#include <string>
#include <string.h>
#include <conio.h>
using namespace std;

class Glump
{
public:
	Glump(string *_name);
	~Glump();

private:
	string name;
	string *_name;
	int ID_num;
	int ID;
};

class Node
{
public:
	Node(Glump *_H, Node *_Next);
	~Node();
	
private:
	Glump *H;
	Node *Next;
};

class Queue
{
public:
	Queue();
	~Queue();
	void Make_Empty(); // resets all values to 0 or -1
	bool is_full() const; // check if queue is full
	bool is_empty() const; // check if queue is empty
	void Enqueue();// adds to queue
	void Dequeue(); // removes from queue
	void Hash(); // hash table function
	void Display( ); // display queue

private:
	static const int Peeps_Limit = 3;// limit of people per que
	static const int Carts_Num = 7; // number of carts in ride
	int HashValue;
	int HashSize;
	int Max;
	int front;
	int rear;
	string* queue;
	int StringLength;
	string rides[Carts_Num][Peeps_Limit];
	

};



.cpp
#include "Horacious_Glump.h"
#include <string>
#include <string.h>

using namespace std;

Glump::Glump(string *_name)
{
	ID = 0;
	int Size = 1;

	for (int i = 0; i <= 21; i++)
	{
		if (_name = '\0')

			break;
		Size++;
	}

	string *name = new string;
	name = new string[Size];

	name = _name;

	ID_num = ID++;
}

Glump::~Glump()
{
	delete[] _name;
}

Node::Node(Glump *_H, Node *_Next)
{
	H = _H;
	Next = _Next;
}

Node::~Node()
{
	delete[] H;
	delete[] Next;
}

Queue::Queue()
{
	int HashValue = 0;
	int HashSize = 7;
	int Max = Peeps_Limit + 1;
	int front = Max - 1;
	int rear = Max - 1;
	string* queue = new string[Peeps_Limit];
	int StringLength = 0;
	string rides[Carts_Num][Peeps_Limit];


}

Queue::~Queue()
{
	delete[] queue;
}

void Queue::Make_Empty()
{
	int HashValue = NULL;
	int HashSize = NULL;
	int Max = NULL;
	int front = NULL;
	int rear = NULL;
	string* queue = NULL;
	int StringLength = NULL;

}

bool Queue::is_empty() const
{
	return (front == rear);
}

bool Queue::is_full() const
{
	return ((rear + 1) % Peeps_Limit == front);
}


void Queue::Enqueue()
{
	const string value; string name; int Name_num;
	cout << "enter the number of names : ";
	cin >> Name_num;

	for (int i = 1; i < Name_num; i++)
	{
		cout << endl << "enter name " << i << " :";
		cin >> name;
		Hash();
		cout << endl << name << " is now in queue.";
	}

	if (is_full())
	{
		cout << "queue is full, please wait " << endl;
		return;
	}
	else
	{
		rear = (rear + 1) % Max;
		queue[rear] = value;
	}
}

void Queue::Dequeue()
{
	const string value;

	if (is_empty())
	{
		cout << "queue is empty, select another slot" << endl;
	}
	else
	{
		front = (front + 1) % Max;
		queue[front] = value;
	}
}

void Queue::Hash()
{
	const string value;

  	StringLength = value.length();
	
	for (unsigned int index = 0; index < StringLength; index++)
	{
		HashValue = (HashValue * 31) + value[index];
		HashValue %= HashSize;
	}
}


void Queue::Display()
{
	for (int i = 0; i <Carts_Num; i++)
		for (int j = 0; j < Peeps_Limit; j++)
			cout << "Ride " << i << "Person: " << rides[i][j] << endl;
}



main

#include <iostream>
#include <conio.h>
#include <time.h>
#include <string>
#include "Horacious_Glump.h"

using namespace std;

int main()
{
	Queue H;
		char in;

		do
		{
			cout << "Kiosk Menu" << endl;
			cout << "0: Exit" << endl;
			cout << "1: Enqueue" << endl;
			cout << "2: Display Queue" << endl;
			cout << "3: Run Rides" << endl;
			cout << "4: Empty Queue" << endl;

			cout << ": ";
			cin >> in;
			cin.sync();

			system("CLS");

			switch (in)
			{
			case '0':  // exit
				return 0;
				break;
			case '1':  // Enqueue
				H.Enqueue();
				break;
			case '2':  // print
				H.Display();
				break;
			case '3':  // dequeue
				H.Dequeue();
				break;
			case '4':
				H.Make_Empty(); // make empty
				break;
			default:
				cout << "\nInvalid Input" << endl;
				break;
			}
		} while (in != '0');

		return 0;
}




when i try to enqueue it is causing a break at the end of the enqueue method... unhandled exception integer dividion by zero... any ideas???

This post has been edited by rookie#9: 03 August 2014 - 03:52 PM

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3574
  • View blog
  • Posts: 11,115
  • Joined: 05-May 12

Re: hash table and queue issues

Posted 03 August 2014 - 07:28 PM

Yeah, it's because your constructor is initializing local variables instead of class variables.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1