In: Computer Science
c++
Please read the instructions carefully. You must put the proper items in the proper file (eitehr SSandwich.h or SSandwich.cpp. Do NOT include any main function in your submission. You are encouraged to write your own main function to test what you are submitting.
You are submit two files via BlackBoard:
A file named SSandwich.h, a header file defining the class SSandwich. No inline methods are permitted. Any enum classes should be defined here also. Your header file should have #includes such that SSandwich.cpp will compile with only a #include ‘‘SSandwich.h’’ as the only #include
A file named SSandwich.cpp, a file that contains the implementation of the member functions for the SSandwich class.
The sloppy sandwich shop is now accepting take-out orders. Please implement code to support online ordering of sandwiches, with the following properties:
The size may be either regular or glutton.
The breadType type may be white, wheat, or rye.
The breadFormat may be wrap, sub, or sliced.
The contentsList (represented by a vector of string) may include any combination of the fol- lowing: Tomato, AmericanCheese, CheddarCheese, Ham, Salami, Onions, Peppers, Mustard, or May- onnaise. (Do NOT check the string is a “valid” content for the sandwich. This will allow for custom requests like “only a little mustard” (in addition to saving you having to write some “tedious” code)).
Create a enum class for the size, breadType, and breadFormat.
Create the class definition for a class SloppySandwitch that supports the above and provide Decla- rations for all of the functions that will be defined in parts B-D. (Note: None of the functions in parts B-D should be written as inline functions. All data members must be private).
Define the following constructors for the SloppySandwitch
class:
• The default constructor so that the sandwich will have the
following properties: size is regular,
breadType is white, and breadFormat is wrap.
• A value constructor that allows the caller to specify all three
values for size, breadType, and
breadFormat.
In both cases, the contentsList initially is empty.
Definepublicaccessormethodstoobtain(astheappropriateenum)size,breadType,andbreadFormat, named getSize, getBreadType, and getBreadFormat.
Also Define public mutator methods named setSize, setBreadType, and setBreadFormat.
Define an overloaded version of the + operator so that the user can add contents to the sandwich. The same item may be added more than once.
// SSandwich.h
#ifndef SSANDWICH_H
#define SSANDWICH_H
#include <string>
#include <vector>
using namespace std;
enum size
{
regular,
glutton
};
enum breadType
{
white,
wheat,
rye
};
enum breadFormat
{
wrap,
sub,
sliced
};
class SloppySandwitch
{
private:
size s;
breadType bType;
breadFormat bFormat;
vector<string> contentsList ;
public:
SloppySandwitch();
SloppySandwitch(size, breadType, breadFormat);
size getSize();
breadType getBreadType();
breadFormat getBreadFormat();
void setSize(size);
void setBreadType(breadType);
void setBreadFormat(breadFormat);
void operator+(string);
};
#endif // SSANDWICH_H
//end of SSandwich.h
// SSandwich.cpp
#include "SSandwich.h"
#include <iostream>
// default constructor
SloppySandwitch::SloppySandwitch() : s(size::regular),
bType(breadType::white), bFormat(breadFormat::wrap)
{}
// parameterized constructor
SloppySandwitch::SloppySandwitch(size s, breadType bType,
breadFormat bFormat): s(s), bType(bType), bFormat(bFormat)
{}
// return size
size SloppySandwitch:: getSize()
{
return s;
}
// return breadType
breadType SloppySandwitch:: getBreadType()
{
return bType;
}
// return breadFormat
breadFormat SloppySandwitch:: getBreadFormat()
{
return bFormat;
}
// set size
void SloppySandwitch:: setSize(size s)
{
this->s = s;
}
// set breadType
void SloppySandwitch:: setBreadType(breadType type)
{
bType = type;
}
// set breadFormat
void SloppySandwitch:: setBreadFormat(breadFormat format)
{
bFormat = format;
}
// add item to contents
void SloppySandwitch:: operator+(string item)
{
contentsList.push_back(item);
}
//end of SSandwich.cpp