Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please check the missing specifications and please add the rest. C++ Inventory Inquisitor Problem: Your significant other has had a flash of inspiration - the

Please check the missing specifications and please add the rest.

C++ Inventory Inquisitor Problem:

Your significant other has had a flash of inspiration - the world needs another inventory management program! You agreed to write it for them because love is indeed blind. Table 1 below has the minimum fields you will need to output, as well as the validation rules for Specification B4.

REQUIRED Specification Bundles:

// Specification C2 - Dynamic Array Create an array on the heap. Initialize it to 1 element. You will add elements as necessary.

// Specification C3 - Resize Array

Allows you to add records to the end of the inventory data structure you created. This is activated with the first menu option above. Create a pTmp pointer variable for the new data structure. You will also subtract elements from the end as well.

//Specification B2 -RandNo Class

Create a random number class, RandNo. You will use this to return the random number for the Wholesale cost (but you can make it flexible for other stuff too if you want). It should know seed initialization state and randomly set it once if needed.

// Specification B3 - Singleton Design Pattern

Use the singleton design pattern to make sure your time set seed code only runs once.

// Specification B4 - Inventory Entry Input Validation Apply the first three validation rules from Table 1 to Add new item and Edit item (Spec A1) menu selections. Re-prompt if incorrect input. Create an InVal class or function to perform this check.

// Specification A2 - Overload operator

Overload the stream extraction operator somewhere in your program. Im guessing the Inventory struct is the easiest place to do this.

// Specification A3 - Overload operator Overload the stream insertion operator for the RandNo class. This will be how you will enter a user specified seed. This method will prompt the user and use the integer value they provide as the random number seed - overwriting the time value if needed.

// Specification A4 - UnitTest() function in main() The UnitTest function is where you call all the ComponentTest() methods from all the classes you use. You also put tests in here to verify your classes do indeed, work together. In this assignment, use this method to call your various ComponentTest() methods. You should have a ComponentTest() method in every class you create.

#include #include #include #include #include #include #include

using namespace std;

class InVal { private: std::string name; // Name of the item std::string description; // Description of the item double price; // Price of the item int quantity; // Quantity of the item public: InVal(const std::string& name, const std::string& description, double price, int quantity) { this->name = name; this->description = description; this->price = price; this->quantity = quantity; } std::string getName() const { return name; } void setName(const std::string& name) { this->name = name; } std::string getDescription() const { return description; } void setDescription(const std::string& description) { this->description = description; } double getPrice() const { return price; } void setPrice(double price) { this->price = price; } int getQuantity() const { return quantity; } void setQuantity(int quantity) { this->quantity = quantity; } void print() const { std::cout << "Name: " << name << std::endl; std::cout << "Description: " << description << std::endl; std::cout << "Price: " << price << std::endl; std::cout << "Quantity: " << quantity << std::endl; } };

class RandNo { private: int minVal; // Minimum value of the random number int maxVal; // Maximum value of the random number public: RandNo(int minVal, int maxVal) { this->minVal = minVal; this->maxVal = maxVal; srand(time(NULL)); // Seed the random number generator with the current time } int get() const { return rand() % (maxVal - minVal + 1) + minVal; } };

class invntry{ public: int qty_in_hand, whlsl_cost, rtl_cost; time_t theTime; struct tm *aTime; string it_name ; invntry(){ theTime = time(NULL); aTime = localtime(&theTime); whlsl_cost = 5; qty_in_hand = 0; };

void add_new(string file); void display_item(string file); void update_item(string file); void delete_item(string file);

}; void invntry::add_new(string file){ int c=1,i=0; string data; ifstream in; in.open(file.c_str()); cout<<"Enter item name: "; cin>>it_name; cout<<"Enter Wholesale cost: "; cin>>whlsl_cost; cout<<"Enter quantity: "; cin>>qty_in_hand; rtl_cost = whlsl_cost * 2; ofstream f; f.open(file.c_str(),ios::app); f <tm_year <<" "; f.close(); cout<<"Item "<

ifstream in,inn; in.open(file.c_str()); while(getline(in, data)) c++; string *items = new string[c]; int *qtys = new int[c]; int *wsc = new int[c]; int *rtc = new int[c]; string itn; int qt,wc,rc; inn.open(file.c_str()); while(getline(inn, data)){ istringstream ss(data); ss>>itn>>qt>>wc>>rc; items[i] = itn; qtys[i] = qt; wsc[i] = wc; rtc[i] = rc; i++; } cout<<"Enter the item name to search: "; cin>>itn; for(int j=0;j

ifstream in,inn; in.open(file.c_str()); while(getline(in, data)) c++; string *items = new string[c]; int *qtys = new int[c]; int *wsc = new int[c]; int *rtc = new int[c]; string itn; int qt,wc,rc; inn.open(file.c_str()); while(getline(inn, data)){ istringstream ss(data); ss>>itn>>qt>>wc>>rc; items[i] = itn; qtys[i] = qt; wsc[i] = wc; rtc[i] = rc; i++; } cout<<"Enter the item name to change: "; cin>>itn; char ch; for(int j=0;j>ch; if(ch == 'n'){ cout<<"Enter new name: "; cin>>itn; items[j]= itn; break; } if(ch == 'q'){ cout<<"Enter new quantity: "; cin>>qt; qtys[j]= qt; break; } if(ch == 'w'){ cout<<"Enter new whole sale price: "; cin>>wc; wsc[j]= wc; break; } if(ch == 'r'){ cout<<"Enter new retail price: "; cin>>rc; rtc[j]= rc; break; } cout<<"The item "<tm_year <<" "; f.close(); } void invntry::delete_item(string file){ int c=0,i=0,flag=0; string data;

ifstream in,inn; in.open(file.c_str()); while(getline(in, data)) c++; string *items = new string[c]; int *qtys = new int[c]; int *wsc = new int[c]; int *rtc = new int[c]; string itn; int qt,wc,rc; inn.open(file.c_str()); while(getline(inn, data)){ istringstream ss(data); ss>>itn>>qt>>wc>>rc; items[i] = itn; qtys[i] = qt; wsc[i] = wc; rtc[i] = rc; i++; } cout<<"Enter the item name to delete: "; cin>>itn; for(int j=0;jtm_year <<" "; } f.close(); } int main(){ invntry inv; int ch; string f; cout<<"Enter file name: "; getline(cin, f);

while(1){ cout<<" Enter your choice "; cout<<"1.Add new record "; cout<<"2.Display any record "; cout<<"3.Change any record "; cout<<"4.Delete any record "; cout<<"5.Exit the program "; cin>>ch; switch(ch){ case 1: inv.add_new(f);break; case 2: inv.display_item(f);break; case 3: inv.update_item(f);break; case 4: inv.delete_item(f);break; case 5: exit(0); default: cout<<"Invalid choice! "; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago