C++   Complete the program that will allow the user to enter data on 10 Halloween costumes. The program will create Costume objects and then store the Costume objects in a Hash Table. The Costume ID will be the key and a pointer to the Costume object will be the value.   You are given Lab7.cpp, HashEntry.h, and Costume.h and you should not have to make any changes to these files at all.   You will need to write HashTable.h, which implements the HashTable class. This should NOT be a template class. Your HashTable class should resolve collisions by linear probing and should use the HashEntry class for the linkedlist nodes. Because we’re using probing, there is no removal function. This is okay for this application, since we want to keep a record of costumes that are no longer being kept in stock.   ---GIVEN--- Lab.cpp #include #include "HashTable.h" #include "Costume.h" using namespace std;   int main() { int size; int key; Costume *newCostume; string name; float price; int stock; cout << "\nHello.\n\n"; cout <<"What size is the table? "; cin >> size; //create a Hash Table HashTable myHashTable(size); //fill the table for(int i=0; i> key; cin.ignore(); cout << "NAME: "; getline(cin, name); cout << "PRICE: $"; cin >> price; cout << "STOCK: "; cin >> stock; newCostume = new Costume(key, name, price, stock); myHashTable.putValue(key, newCostume); } cout << "\n\nHERE IS THE TABLE:\n\n"; myHashTable.printHashTable(); cout << endl << endl; return 0; }   HashEntry.h #ifndef HASHENTRY_H #define HASHENTRY_H   #include #include "Costume.h" using namespace std;   class HashEntry { private: int key; Costume* value; public: HashEntry(int k, Costume* v) { this->key = k; this->value = v; } int getKey() { return key; } Costume* getValue() { return value; } void setValue(Costume* v) { value = v; } };   #endif   Costume.h #ifndef COSTUME_H #define COSTUME_H   #include using namespace std;   class Costume { private: //attributes int id; // costume id string costumeName; float price; int stock; public: Costume(int id, string name, float price, int stock){ this->id = id; this->costumeName = name; this->price = price; this->stock = stock; } int getID() const { return this->id; } string getCostumeName() const { return this->costumeName; } float getPrice() const { return this->price; } int getStock() const { return this->stock; } void setStock(int newStock) { stock = newStock; } friend ostream & operator<< (ostream & os, Costume c) { os << c.getID() << ", " << c.getCostumeName(); return os; } };   #endif

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++

 

Complete the program that will allow the user to enter data on 10 Halloween costumes. The program will create Costume objects and then store the Costume objects in a Hash Table. The Costume ID will be the key and a pointer to the Costume object will be the value.

 

You are given Lab7.cpp, HashEntry.h, and Costume.h and you should not have to make any changes to these files at all.

 

You will need to write HashTable.h, which implements the HashTable class. This should NOT be a template class. Your HashTable class should resolve collisions by linear probing and should use the HashEntry class for the linkedlist nodes. Because we’re using probing, there is no removal function. This is okay for this application, since we want to keep a record of costumes that are no longer being kept in stock.

 

---GIVEN---

Lab.cpp

#include <iostream>

#include "HashTable.h"

#include "Costume.h"

using namespace std;

 

int main()

{

int size;

int key;

Costume *newCostume;

string name;

float price;

int stock;

cout << "\nHello.\n\n";

cout <<"What size is the table? ";

cin >> size;

//create a Hash Table

HashTable myHashTable(size);

//fill the table

for(int i=0; i<size; i++)

{

cout << "\n*****COSTUME " << i+1 << "*****\n";

cout << "COSTUME ID: ";

cin >> key;

cin.ignore();

cout << "NAME: ";

getline(cin, name);

cout << "PRICE: $";

cin >> price;

cout << "STOCK: ";

cin >> stock;

newCostume = new Costume(key, name, price, stock);

myHashTable.putValue(key, newCostume);

}

cout << "\n\nHERE IS THE TABLE:\n\n";

myHashTable.printHashTable();

cout << endl << endl;

return 0;

}

 

HashEntry.h

#ifndef HASHENTRY_H

#define HASHENTRY_H

 

#include <iostream>

#include "Costume.h"

using namespace std;

 

class HashEntry

{

private:

int key;

Costume* value;

public:

HashEntry(int k, Costume* v)

{

this->key = k;

this->value = v;

}

int getKey()

{

return key;

}

Costume* getValue()

{

return value;

}

void setValue(Costume* v)

{

value = v;

}

};

 

#endif

 

Costume.h

#ifndef COSTUME_H

#define COSTUME_H

 

#include <iostream>

using namespace std;

 

class Costume

{

private:

//attributes

int id; // costume id

string costumeName;

float price;

int stock;

public:

Costume(int id, string name, float price, int stock){

this->id = id;

this->costumeName = name;

this->price = price;

this->stock = stock;

}

int getID() const

{

return this->id;

}

string getCostumeName() const

{

return this->costumeName;

}

float getPrice() const

{

return this->price;

}

int getStock() const

{

return this->stock;

}

void setStock(int newStock)

{

stock = newStock;

}

friend ostream & operator<< (ostream & os, Costume c)

{

os << c.getID() << ", " << c.getCostumeName();

return os;

}

};

 

#endif

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education