Question: This C++ project extends the labs on the class shoeType, done on April 3 and April 10. Use your header file shoeType.h which has six
This C++ project extends the labs on the class shoeType, done on April 3 and April 10. Use your header file shoeType.h which has six data members in the shoeType class (including stock), and has the previously used member function definitions. NOTE: You may add class member functions to the shoeType class, in your header file, as needed. Remember that class functions are typically set or get functions for class data members. Do NOT put functions that belong in main( ) in the class definition!
For the April 10 lab, you developed a main program which declared an array of shoeType objects, called an input function to read shoe data from an input file to put values in some of the array objects, and used a for loop to print the data in the objects that received input data. You will use these features, and extend the actions to be performed on the shoeType objects. Declare an array named shoeStore, consisting of shoeType objects. Call the input function to read in the array data from the input file shoeData.txt, as before. Then add functions as needed for a user-driven program to allow the user to ? Add a shoe the user specifies the shoe member data by keyboard input ? Print all shoes data ? Print a particular shoes data the user can specify shoe ID ? Update the inventory the user specifies shoe ID and an integer (positive or negative) to be added to the number of pairs on hand (stock data member) ? Sell some number of a particular shoe the user specifies the shoe ID and the number of pairs to be sold Have a Menu function which presents these choices to the user, and returns the users selection. (One example of a menu function is in the Candy Machine example at the end of the chapter on classes.) Here is the header file:
#include
class shoeType { private: double size, price; string style, iD, width;
public:
shoeType() { size = 0.0; price = 0.0; width = ""; style = ""; iD = ""; }
shoeType(double s, double p, char w, string st, string id) { size = s; price = p; width = w; style = st; iD = id; }
void reSetPrice() { cout << "Whoops wrong price :" << endl; cin >> price; }
void print() { cout << "So what are eyou looking for? " << endl; cout << "Size: " << size << endl; cout << "price " << price << endl; cout << "width " << width << endl; cout << "Style: " << style << endl; cout << "ID:" << iD << endl;; }
void setAll() { cout << "What is your size: " << endl; cin >> size;
cout << "What's the price: " << endl; cin >> price;
cout << "Let's see that foot : " << endl; cin >> width;
cout << "What style do you like: " << endl; cin >> style;
cout << "Let me find the ID for ya: " << endl; cin >> iD; } };
Here is the main:
#include
#include "shoeType.h"
int main() { shoeType shoe; shoeType shoe2(11.0, 150.00, 'R', "Sneaker", "A108");
shoe.print(); shoe2.print();
shoe.setAll();
shoe.reSetPrice();
shoe.print(); shoe2.print();
system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
