Question: In this assignment, you will practice utilizing regular expressions. Instructions Assignment Header At the top of each of your C + + programs, you should

In this assignment, you will practice utilizing regular expressions.
Instructions
Assignment Header
At the top of each of your C++ programs, you should have at least four lines of documentation:
Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example:
/* Program name: jbtictactoe.cpp
* Author: John Doe
* Date last updated: 5/1/2017
* Purpose: Play the game of Tic-Tac-Toe
*/
Assignment: Burger Toppings
Create a set class that contains an AVLTree. The set class should be templated. To navigate your set you will need an iterator, so you will be provided with a modified version of the AVLTree that contains an Iterator as a nested class.
You will be given a burger class that contains an enum for the burger toppings. You will need to modify the class so that the burger class contains a set of toppings that uses your custom set class. Add a function that allows a topping to be added to the burger, and change the getToppings function so that it turns all of the toppings in the set into a string. In the main, you will modify the provided code so that the toppings picked by the user will be added to a burger object. The will be limited tests run on this code.
heres burger.cpp
#include "burger.h"
burger::burger(int numPatties)
{
setNumPatties(numPatties);
}
std::string burger::getToppings()
{
std::string c;
c = toppingStr[toppings[0]];
for (int i =1; i < numToppings; i++)
{
c +=","+ toppingStr[toppings[i]];
}
return c;
}
void burger::setNumPatties(int num)
{
if (num >0)
numPatties = num;
else
std::cout << "The number of patties should be greater than 0."<< std::endl;
}
std::string burger::tostring()
{
std::ostringstream out;
out << std::setprecision(2)<< std::fixed << std::showpoint;
out << "Number of patties: "<< numPatties << std::endl;
out << "Toppings: "<< getToppings();
return out.str();
}
heres burger.h
#pragma once
#include
#include
#include
#include
#include
#include
const int TOP_NUM =8;
enum toppingType
{
GRILLONION,
RAWONION,
TOMATO,
LETTUCE,
BACON,
MUSHROOM,
PICKLE,
NOTOP
};
const std::string toppingStr[]={"Grilled Onion",
"Raw Onion",
"Tomato",
"Lettuce",
"Bacon",
"Grilled Mushroom",
"Pickle",
"None"};
const toppingType toppingList[]={
GRILLONION,
RAWONION,
TOMATO,
LETTUCE,
BACON,
MUSHROOM,
PICKLE, NOTOP};
class burger
{
public:
burger(int numPatties);
std::string getToppings();
void addTopping(toppingType);
std::string tostring();
void setNumPatties(int num);
int getNumPatties() const;
private:
toppingType toppings[7];
make a set int numToppings;
This should come from the set
int numPatties;
};
heres main.cpp
#include
#include
#include
#include
#include "burger.h"
void resetStream();
int promptNumPatties();
void promptToppings(toppingType[], int &);
int main()
{
int pat = promptNumPatties();
toppingType top[7];
int topCount;
promptToppings(top, topCount);
burger myBurger(pat);
std::cout << myBurger.tostring()<< std::endl;
}
void resetStream()
{
std::cin.clear();
std::cin.ignore(std::numeric_limits::max(),'
');
}
int promptNumPatties()
{
int pat;
std::cout << "How many patties do you want on your burger? ";
std::cin >> pat;
std::cout << std::endl;
if (std::cin && pat >0)
{
return pat;
}
else if (!std::cin)
{
resetStream();
}
std::cout << "You entered an invalid amount of patties. Please try again." << std::endl;
return promptNumPatties();
}
void promptToppings(toppingType top[], int &count)
{
int topInt;
count =0;
for (int i =0; i <7; i++)
{
std::cout << "Please choose a topping from the list. Enter -1 to stop adding toppings." << std::endl;
for (int i =0; i < TOP_NUM; i++)
{
std::cout << i +1<<": "<< toppingStr[i]<< std::endl;
}
std::cin >> topInt;
std::cout << std::endl;
if (topInt ==-1)
break;
while (!std::cin || topInt <=0|| topInt > TOP_NUM)
{
if (!std::cin)
resetStream();
std::cout << "You did not choose a valid topping. Please try again." << std::endl;
std::cin >> topInt;
std::cout << std::endl;
}
top[count++]= toppingList[topInt -1];
if (topInt ==8)
{
break;
}
}
}
heres set.h
#ifndef SET_H
#define SET_H
#include "AVLTree.h"
#endif
heres binarysearchtree.h
#ifndef SEARCH_H
#define SEARCH_H
#include "binaryTree.h"
#include
template
class binarySearchTree : public binaryTree
{
public:
void insert(const t &insertItem);
bool search(const t &searchItem);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!