Question

In: Computer Science

Code the following in C++ and make sure to include all three files required at the...

Code the following in C++ and make sure to include all three files required at the end.

Hotdogs – The World’s Greatest Cost Effective Wholesome Nutritious Food
Due to world food supply scarcity and the burgeoning populations of the world’s countries, your hot stand business is
globalizing to satisfy the world’s desire for a cost effective wholesome nutritious food source. Market studies have
shown that tens of billions of people are craving for the eponymous hotdog which will result in a huge number of hotdog
sales from hotdog stands. You need to develop a program that tracks the activities of all the hotdog stands.
HotDogStandsClass
Define a class named HotDogStandsClass.
This class has the following for private member instance variables:
• Hotdog stand Identification
Each stand should have a unique identification
• Stand Location
A string that is the address of the stand which includes street, city and country.
For examples:
12 Deepika Padukone Ci, Bangelore, Karnataka 67089, India
1038 West Nanjing Rd, Westgate Mall, 8th Floor, Shanghai, Shanghai 200041, China
123 Jennifer Dr, UTD Food Court, 2nd Floor, Richardson Texas, 66666, USA
• Cost per hotdog
Cannot be negative, must be 0 or greater.
• Total Hot Dogs Sold Across All Stands
Cannot be negative, must be 0 or greater.
• Hotdogs Inventory Amount
The lowest value the inventory can be is 0. Negative inventory amounts do not make sense.
• Hotdogs Sold Count
This contains how many hot dogs this stand has sold since the stand object was created.
The HotDogStandsClass Class must include the following methods
• A constructor with parameters that sets all the instance values
• Accessor (Getter) and Setter methods that are required for all private member instance variables
• hotDogsBuy(n) method
• The method will be invoked each time someone (your main method test driver) wants to buy some hotdog(s).
• Has a parameter (n) that indicates the requested amount of hotdogs to be bought
• If the inventory is 0, the method should display a message that there are no more hotdogs left to be sold.
The method uses the amount of the hot dogs requested to:
• Increase the hog dogs total number sold for all the stands by the hotDogsBuy(n) parameter amount
It must be accessible to all the HotDogStandsClass objects.
• Increase the tracked hot dogs sold by the appropriate numberfor each stand
• Decrease the hot dog inventory by the appropriate number
• This method should be intelligent regarding the inventory.
The lowest value the inventory can be is 0. Negative inventory amounts do not make sense.
If the buy amount is more than the inventory, the class should state the number of hotdogs in inventory and
state to retry a buy.
If inventory amount is 0, the class should state that it is out of hotdogs and to try again later.
hopefully before a buy retry a stock inventory will be done.
• a stockInventory(n) method that is used to add inventory
Has a parameter (n) that indicates the requested number of hotdogs to be stocked

main()
This main program has the following:
The main program must create and use at least three hot dog stand objects of the HotDogStandsClass.
Write a main() test driver, a concept that is demonstrated in the book, to test the HotDogStands program. The main
test driver must test all paths of the logic flow of the program and conditions of the program to validate program
correctness.
Do not use any interactive prompts, unit test the HotdogStandsClass by coding in test scenarios in the main program
which will act as a test driver.
The main unit test driver must display information that indicates what is being tested with the test values being used
and after perfoming the hotdog stand operatiomn will display the state of the HotDogStandClass.
To accomplish this display of the class state, you should develop an overloaded stream output operator that displays a
well formatted string of object state (contents) that is well suited to being displayed using cout.
The output must be well formatted and readable to the user running the program. The main test unit driver does not
have to output if the test passed or failed, just what is being tested in the object of the class for each test and the class
state using the overloaded stream output operator (<<).
Use the following code to pause the screen:
#include <stdio.h>
:
cout << "Press the enter key to continue..." << endl; cin.ignore(); cin.get();
There is a system dependency that may require hitting the key twice for correct behavior.
Example:
HotDogStandClass hotdogstand1;
cout << “ buy 20 hot dogs “ << endl;
hotdogstand1.buy(20);
cout << hotdogstand1 << endl;
cout << “Press enter to continue”; cin.ignore(); cin.get();
You will lose points if the main function does not do comprehensive path testing of the program.
Before the program ends, the main part should display the total amount sold and display the final states of each of the
objects of the HotDogStandsClass.
The program must hold the screen for each unit test so that the class information can read.
Your program must use the class specification and class implementation design paradigms.
Therefore, you will have multiple files to upload for submittal to the eLearning system:
main.cpp
HotDogStandsClass.h
HotDogStandsClass.cpp

Solutions

Expert Solution

Ans)

//HotDogStandsClass.h

#ifndef HOTDOGSTANDSCLASS_H
#define HOTDOGSTANDSCLASS_H
#include <iostream>
#include <string>

using namespace std;

// Defines class HotDogStand
class HotDogStand
{
public:
// Prototype of member functions
HotDogStand();
HotDogStand(string, string, string, string, int);
void setID(string);
void setLication(string, string, string);
void setInventoryAmount(int);

string getID() const;
string getLication() const;
int getInventoryAmount() const;
int getTotalSold() const;
int getSoldCount() const;

void hotDogsBuy(int);
void stockInventory(int);

friend ostream & operator <<(ostream &, HotDogStand &);

private:
// Data member to store hot dog information
string ID;
string street, city, country;
int totalSold;
static int inventoryAmount;
int soldCount;
};
int HotDogStand::inventoryAmount = 0;
#endif // ! HOTDOGSTANDSCLASS_H

-------------------------------------------------------------------------------------------------

//HotDogStandsClass.cpp

#include "HotDogStandsClass.h"
using namespace std;

// Default constructor to assign default values to data member
HotDogStand::HotDogStand()
{
ID = street = city = country = "";
totalSold = inventoryAmount = soldCount = 0;
}// End of default constructor

// Parameterized constructor to assign parameter values to data member
HotDogStand::HotDogStand(string id, string st, string ci, string co, int amt)
{
ID = id;
street = st;
city = ci;
country = co;
// Calls the function to validate and assigns the parameter amount
setInventoryAmount(amt);
totalSold = soldCount = 0;
}// End of parameterized constructor

// Function to set id
void HotDogStand::setID(string id)
{
ID = id;
}// End of function

// Function to set location
void HotDogStand::setLication(string st, string ci, string co)
{
street = st;
city = ci;
country = co;
}// End of function

// Function to set inventory amount
void HotDogStand::setInventoryAmount(int amt)
{
// Checks if amount is less then 0 then set it to 0 after displaying error message
if(amt < 0)
{
cout<<"\n Invalid amount.";
inventoryAmount = 0;
}// End of if condition

// Otherwise assigns the parameter amount
else
inventoryAmount = amt;
}// End of function

// Function to return id
string HotDogStand::getID() const
{
return ID;
}// End of function

// Function to return location0
string HotDogStand::getLication() const
{
return street + ", " + city + ", " + country;
}// End of function

// Function to return inventory amount
int HotDogStand::getInventoryAmount() const
{
return inventoryAmount;
}// End of function

// Function to return total sold
int HotDogStand::getTotalSold() const
{
return totalSold;
}// End of function

// Function to return sold count
int HotDogStand::getSoldCount() const
{
return soldCount;
}// End of function

// Function to bub dog
void HotDogStand::hotDogsBuy(int n)
{
// Checks if inventory amount is 0 then display error message
if(inventoryAmount == 0)
cout<<"\n Insufficient inventory amount to purchase.";

// Otherwise checks if inventory amount is less than the parameter amount
// display error message
else if(inventoryAmount < n)
cout<<"\n Insufficient inventory amount "<<inventoryAmount
<<"\n Your request is more than the available. Try later.";

// Otherwise update data
else
{
inventoryAmount -= n;
totalSold += n;
soldCount++;
}// End of else
}// End of function

// Function to increase the inventory amount by the parameter amount
void HotDogStand::stockInventory(int n)
{
inventoryAmount += n;
}// End of function

// Overrides << operator to return hot dog information
ostream & operator <<(ostream &out, HotDogStand &hd)
{
out<<"\n\n ID: "<<hd.getID()<<"\n Location: "<<hd.getLication()
<<"\n Inventory Amount: "<<hd.getInventoryAmount()
<<"\n Total Sold: "<<hd.getTotalSold()
<<"\n Sold Count: "<<hd.getSoldCount();
return out;
}// End of function

// main function definition
int main()
{
// Creates two object of class HotDogStand using parameterized constructor
HotDogStand *hd1 = new HotDogStand("111", "12 Deepika", "Bangalore", "India", 900);
HotDogStand *hd2 = new HotDogStand("222", "11 Rukmini", "Mumbai", "India", 400);

// Calls the function to test
cout<<"\n Initial Status for HD1\n";
cout<<*hd1;
cout<<"\n After buying 50 for HD1 status\n";
hd1->stockInventory(50);
cout<<*hd1;

cout<<"\n After selling 10 for HD1 status\n";
hd1->hotDogsBuy(10);
cout<<*hd1;

cout<<"\n After selling 90 for HD1 status\n";
hd1->hotDogsBuy(90);
cout<<*hd1;

cout<<"\n Initial Status for HD2\n";
cout<<*hd2;
cout<<"\n After buying 50 for HD2 status\n";
hd2->stockInventory(50);
cout<<*hd2;

cout<<"\n After selling 10 for HD2 status\n";
hd2->hotDogsBuy(10);
cout<<*hd2;

cout<<"\n After selling 90 for HD2 status\n";
hd2->hotDogsBuy(90);
cout<<*hd2;
return 0;
}

Output

Initial Status for HD1

ID: 111

Location: 12 Deepika, Bangalore, India

Inventory Amount: 400

Total Sold: 0

Sold Count: 0

After buying 50 for HD1 status

ID: 111

Location: 12 Deepika, Bangalore, India

Inventory Amount: 450

Total Sold: 0

Sold Count: 0

After selling 10 for HD1 status

ID: 111

Location: 12 Deepika, Bangalore, India

Inventory Amount: 440

Total Sold: 10

Sold Count: 1

After selling 90 for HD1 status

ID: 111

Location: 12 Deepika, Bangalore, India

Inventory Amount: 350

Total Sold: 100

Sold Count: 2

Initial Status for HD2

ID: 222

Location: 11 Rukmini, Mumbai, India

Inventory Amount: 350

Total Sold: 0

Sold Count: 0

After buying 50 for HD2 status

ID: 222

Location: 11 Rukmini, Mumbai, India

Inventory Amount: 400

Total Sold: 0

Sold Count: 0

After selling 10 for HD2 status

ID: 222

Location: 11 Rukmini, Mumbai, India

Inventory Amount: 390

Total Sold: 10

Sold Count: 1

After selling 90 for HD2 status

ID: 222

Location: 11 Rukmini, Mumbai, India

Inventory Amount: 300

Total Sold: 100

Sold Count: 2

*********************-end **************

if your satisfy above answer please give positive rating or?

if any doubts below comment here

please don't dislike or downvote

Thankyou!


Related Solutions

Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argb, char *argv[]){ char ch; int upper=1; if(argb>1){ if(strcmp(argv[1],"-s")==0){ upper=1; } else if(strcmp(argv[1],"-w")==0){ upper=0; } } while((ch=(char)getchar())!=EOF){ if(upper){ printf("%c",toupper(ch)); } else{ printf("%c",tolower(ch)); } } return 0; } ======================================================== #include <stdio.h> #include <stdlib.h> int calcRange(int array[],int size){ int max=array[1]; int min=array[0]; int a=0; for(a=1;a<size;a++){ if(array[a]>max){ max=array[a]; } } for(a=1;a<size;a++){ if(array[a]<min){ min=array[a]; } } printf("%d-%d=%d\n",max,min,max-min); } int main(int arga, char **argv){...
Make sure to include comments that explain all your steps (starts with #) Make sure to...
Make sure to include comments that explain all your steps (starts with #) Make sure to include comments that explain all your steps (starts with #) Write a program that prompts the user for a string (a sentence, a word list, single words etc.), counts the number of times each word appears and outputs the total word count and unique word count in a sorted order from high to low. The program should: Display a message stating its goal Prompt...
Please write code in C++ and include all header files used not bits/stdc: (Same number subsequence)...
Please write code in C++ and include all header files used not bits/stdc: (Same number subsequence) Write an O(n) program that prompts the user to enter a sequence of integers ending with 0 and finds longest subsequence with the same number. Sample Run Enter a series of numbers ending with 0: 2 4 4 8 8 8 8 2 4 4 0 The longest same number sequence starts at index 3 with 4 values of 8
Do a hypothesis for the following, make sure to include and label all five steps:    ...
Do a hypothesis for the following, make sure to include and label all five steps:     Test the claim that the proportion of wins is the same whether the wear a shirt     and tie or jeans and a t-shirt. Use a .05 significance level.             Win Loss Suit and Tie 23 38 Jeans and T-shirt 28 24
<<Importing Data>> Make sure you have downloaded all the data files off Blackboard. There should be...
<<Importing Data>> Make sure you have downloaded all the data files off Blackboard. There should be folders containing images and audio files as well as a selection of CSV and Excel spreadsheets. The following exercises will allow you to practice using MATLAB’s import/export functions. Task 4 – Importing Excel Spreadsheets Exercise: Import the spreadsheet ‘buildings.xls’ which contains all the buildings in the world over 300 metres tall. Plot the number of floors vs. building height using a scatter plot. Reflection:...
learn about Adjusting Entries. These are internal transactions that are required to make sure that all...
learn about Adjusting Entries. These are internal transactions that are required to make sure that all of the revenue and expenses are accurately recorded in the accounting period. They're also important so that our amounts recorded in the Balance Sheet are correct. There are four categories of Adjusting Entries: Prepaid Expenses (including Depreciation), Unearned Revenue, Accrued Expenses and Accrued Revenue. Within each of these categories, there are a lot of examples that we could show. For this graded discussion, please...
C Code Edit this code to make it output all unique letters IN LOWERCASE of an...
C Code Edit this code to make it output all unique letters IN LOWERCASE of an input file. For example, with this input: Raspberry Grapefruit Straw berry raspBERRY Blue$$berry apple Pine_apple raspberry The output should be: raspberry grapefruit straw berry blue berry apple pine NOTE: Words with different capitlization, like raspberry and raspBERRY count as 1 unique word, so raspberry should only be seen once in the output. #include <stdio.h> #include <stdlib.h> int main() {     //Pointer to access the...
C++ CODE ONLY Using the following code. #include <iostream> #include <string> #include <climits> #include <algorithm> using...
C++ CODE ONLY Using the following code. #include <iostream> #include <string> #include <climits> #include <algorithm> using namespace std; // M x N matrix #define M 5 #define N 5 // Naive recursive function to find the minimum cost to reach // cell (m, n) from cell (0, 0) int findMinCost(int cost[M][N], int m, int n) {    // base case    if (n == 0 || m == 0)        return INT_MAX;    // if we're at first cell...
C++ CODE PLEASE MAKE SURE TO USE STRINGSTREAM AND THAT THE OUTPUT NUMBER ARE CORRECT 1....
C++ CODE PLEASE MAKE SURE TO USE STRINGSTREAM AND THAT THE OUTPUT NUMBER ARE CORRECT 1. You must call all of the defined functions above in your code. You may not change function names, parameters, or return types. 2. You must use a switch statement to check the user's menu option choice. 3. You may create additional functions in addition to the required functions listed above if you would like. 4. If user provides option which is not a choice...
How can I edit this C code to make sure that the letter P and L...
How can I edit this C code to make sure that the letter P and L would show up separately one at a time on an interval of one second on a raspberry pi? 1 #include <stdio.h> 2 #include <unistd.h> 3 #include "sense.h" 4 5 #define WHITE 0xFFFF 6 7 int main(void) { 8     // getFrameBuffer should only get called once/program 9     pi_framebuffer_t *fb=getFrameBuffer(); 10     sense_fb_bitmap_t *bm=fb->bitmap; 11 12      bm->pixel[0][0]=WHITE; 13      bm->pixel[0][1]=WHITE; 14      bm->pixel[0][2]=WHITE; 15      bm->pixel[0][3]=WHITE; 16      bm->pixel[0][4]=WHITE; 17      bm->pixel[0][5]=WHITE;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT