Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please teach me how to write C++ code. I need 4 separate files (Store.cpp Store.h Toys.cpp Toys.h) Test Program Except for the mandatory sections of

Please teach me how to write C++ code.

I need 4 separate files (Store.cpp Store.h Toys.cpp Toys.h)

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Test Program

image text in transcribed

image text in transcribed

Except for the mandatory sections of DIY, all the other parts can be changed by students if they find it necessary as long as the program produces an output that exactly matches the required output. Please note that you can (and probably should) add more member functions to make the DIY part work. Your task for this part is to create a program that provides a class called Store. This class can be instantiated by store name and the number of toys that can be added. Then the Toys will be added one at a time to the Store by toy name, SKU number, price and toy age. A toy can be searched by its SKU number to find out if it is on sale or not. The Stores Toy list then can be displayed as follows, listing all the toys' names, their SKU numbers, age and price. Price varies and depends on if toys are on sale or not. Sample List Implementation Implement this program in two modules (i.e., classes): Store and Toys Store Module define the following constant in the Store header file: MAX_NUM_TOYS; //define it to 10. The maximum number of toys that could be added. MAX_SNAME; // define it to 31. The maximum length of a store name The Store class should have the following member variables: - char m_sName;// Store name, up to MAX_SNAME size - int m_noOfToys://No of toys; - int m_addToys;/o of toys added - Toys m_toy;// statically array of toys with size MAX_NUM_TOYS The followings are the mandatory public member functions: - void setStore(const char* sName, int no); This will set the store name and the number of toys that could be added to the store. For invalid value, it will set the values to an empty state. - void setToys(const char* tname, int sku, double price,int age); This will add the toys one at a time to the m_toy array and will keep track of the number of toys added. Toys will be added until num of added toys is less than m_noOfToys - void display()const; If a Store object is valid a) prints "*" with width 60 and fill with "*", then print m_sName and a new line. b) prints "*" with width 60 and fill with "*", then prints "list of the toys" and a new line. c) prints "SKU" with width 30 and fill with empty spaces d) prints "Age" with width 10 and fill with empty spaces e) prints "Price" with width 11 and fill with empty spaces f) prints "Sale" with width 10 and fill with empty spaces then a new line g) prints all the toys information. For details see the sample output. 2. otherwise prints, "Invalid Store" then a new line. - void find(int sku); This method will go through the arrays of toys. It will match the received SKU number with the stored toys' SKU number to find out if the toys are on sale or not. If the number matches then it will pass true to the appropriate Toys method. After that, it will call the calSale() of the toys class to know the sale value. - void setEmpty(; set the store to an empty state Toys Module define the following constant in the Toys header file: MAX_TNAME; // define it to 31. The maximum length of a Toy name The Toy class should have the following member variables: - char m_tname;// toy name, up to MAX_TNAME size - int m_sku; //SKU number, maximum 8 digits long - double m_price;//toy price - int m_age;//toy according to age group - bool m_onSale;// keep track, if toys are on sale or not The followings are the mandatory public member functions: - void addToys(const char* tname, int sku, double price,int age); After checking the validity, this method will set the received values to the appropriate data members. Otherwise will be set to an empty state. - void isSale(bool sale); It will assign the received value to the data member m_onSale. - void calSale(); It will decrease the toys price to 20% then the original price. - void display()const; If a Toy object is valid a) prints m_tname with width 15 , left justified and filled with empty spaces. b) prints msku with width 10 c) prints m_age with width 6 d) prints m_price with width 12 and after the decimal point 2 digits. e) If the toy is on sale it will print "On Sale" with width 10. Otherwise, print empty spaces with width 8. 2. otherwise prints, "Invalid Toy". Execution Sample

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions