Question

In: Computer Science

c++ Please read the instructions carefully. You must put the proper items in the proper file...

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:

  1. 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

  2. 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.

  1. 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).

  2. 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.

  3. Definepublicaccessormethodstoobtain(astheappropriateenum)size,breadType,andbreadFormat, named getSize, getBreadType, and getBreadFormat.

    Also Define public mutator methods named setSize, setBreadType, and setBreadFormat.

  4. 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.

Solutions

Expert Solution

// 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


Related Solutions

****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT...
****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT IS REQUIRED FOR USE IN THE PROBLEM**** You are to generate a list of customers to serve based on the customer’s priority, i.e. create a priority queue/list for a local company. The company has been receiving request and the request are recorded in a file, in the order the request was made. The company processes each user based on their priority, the highest priority...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully the attached document and then post your comments bearing in mind the following questions: 1- What are the pros and cons of rent controls? 2- Why economists disagree on the usefulness of rent control? 3- Do you believe rent control can help the poor? Edit Wiki Content rent control Rent regulation can take various forms, including rent control (the placing of a cap on...
Instructions – PLEASE READ THEM CAREFULLY The Assignment must be submitted on Blackboard (WORD format only)...
Instructions – PLEASE READ THEM CAREFULLY The Assignment must be submitted on Blackboard (WORD format only) via allocated folder. Assignments submitted through email will not be accepted. Students are advised to make their work clear and well presented, marks may be reduced for poor presentation. This includes filling your information on the cover page. Students must mention question number clearly in their answer. Late submission will NOT be accepted. Avoid plagiarism, the work should be in your own words, copying...
Instructions – PLEASE READ THEM CAREFULLY The Assignment must be submitted on Blackboard (WORD format only)...
Instructions – PLEASE READ THEM CAREFULLY The Assignment must be submitted on Blackboard (WORD format only) via allocated folder. Assignments submitted through email will not be accepted. Students are advised to make their work clear and well presented, marks may be reduced for poor presentation. This includes filling your information on the cover page. Students must mention question number clearly in their answer. Late submission will NOT be accepted. Avoid plagiarism, the work should be in your own words, copying...
Please make sure to read the instructions carefully! Must use P8! (A) Write the following assembly...
Please make sure to read the instructions carefully! Must use P8! (A) Write the following assembly language program. Start at 6 and counts down by 2 to 0. (No Loops!) Comment each line except STOP and .END. Add something to the output that makes this program uniquely yours. Cut and paste the Assembler Listing into your document. (B) Paste a screenshot of the Output area of the Pep8. (C) Explain the status bits NZVC at the point STOP is loaded....
Project Instructions Please read the following instructions and review the table below carefully. Then, enter answers...
Project Instructions Please read the following instructions and review the table below carefully. Then, enter answers for journal items [A] to [V] in the next item in this lesson, called Project 1 Part 1 Journal Entries for Accrual Accounting. You may keep these instructions open in a separate browser or download the instructions as a PDF, and open it as you work through the exercise. Illini Company, Inc. Balance Sheet as of 12/31/20X0 Assets Current Assets: Cash 1,500,000 Accounts receivable,...
Please Read Carefully Before start answering this question. Please follow the instructions. This Question is from...
Please Read Carefully Before start answering this question. Please follow the instructions. This Question is from 'BSBFIM501 Manage budgets and financial plans' course. There are no parts missing for this Question; guaranteed!. This is the original Screenshot direct from the question. Therefore, there are nothing any further information can be provided. Thanks for your understanding and Cooperation. Please answer the following questions from the topics discussed for Prepare, implement, monitor and modify contingency plans: 1.a. Explain the process of preparing...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. PLEASE READ CAREFULLY. alot of people give...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. PLEASE READ CAREFULLY. alot of people give me either partial answers, or incorrect skeleton. PLEASE YOU CAN'T CHANGE WHAT IS THERE, YOU CAN ONLY ADD. void readFile(Candidate candidates[]) – reads the elections.txt file, fills the candidates[] array. Hint: use substr() and find() functions. Set Score to 0. void List(Candidate candidates[]) – prints the array of Candidate structs. One candidate per one line, include all fields. Use setw() to display nice looking...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. PLEASE READ CAREFULLY. alot of people give...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. PLEASE READ CAREFULLY. alot of people give me either partial answers, or incorrect skeleton. PLEASE YOU CAN'T CHANGE WHAT IS THERE, YOU CAN ONLY ADD. void readFile(Candidate candidates[]) – reads the elections.txt file, fills the candidates[] array. Hint: use substr() and find() functions. Set Score to 0. void List(Candidate candidates[]) – prints the array of Candidate structs. One candidate per one line, include all fields. Use setw() to display nice looking...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? *IMPORTANT* PLEASE READ CAREFULLY....
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? *IMPORTANT* PLEASE READ CAREFULLY. WE HAVE TO DO WHAT THIS ASSIGNMENT DOES OR WE WILL MARKED OFF POINTS. IT DOES NOT HELP WHEN YOU CHANGE THE SKELETON TO YOU'RE PREFERENCE. THIS IS FOR A BASIC C++ LEVEL CLASS SO WE HAVE TO STICK TO BASIC C++ CODE. HOWEVER IT COULD BE WRONG IN TERMS OF WORKING CONDITIONS SO PLEASE HELP FIX THESE. *IMPORTANT* void readFile(Candidate candidates[]) – reads...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT