Your task for this part is to develop a program that provides a class called Store. This
Question:
Your task for this part is to develop 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:
************************************************************
****Children`s Dream store****
************************************************************
list of the toys
SKU Age Price Sale
Toy[1] :Racing Car 11223344 8 40.99
Toy[2] :Teddy Bear 33772346 6 20.79 On Sale
Toy[3] :Airplane 44453466 16 60.99
Toy[4] :Doll 55887896 5 45.99
Toy[5] :Drone 99221388 18 72.79 On Sale
Toy[6] :Lego 88224596 10 52.79 On Sale
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;//no 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.
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 m_sku 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.
otherwise prints, "Invalid Toy".
main.cpp =
/***********************************************************************
// DO NOT MODIFY
// DO NOT MODIFY
// DO NOT MODIFY
/main.cpp
***********************************************************************/
#include
#include
#include"Store.h"
using namespace std;
using namespace sdds;
int main() {
Store s;
cout << "Printing invalid list of Toys" << endl;
s.setStore("****Children`s Dream store****", 2);
s.setToys(nullptr, 20304576,12.50,2);
s.setToys("Car",203045,11.50,12);
s.display();
cout << endl << "Printing valid list of Toys" << endl;
s.setStore("****Children`s Dream store****", 6);
s.setToys("Racing Car",11223344, 40.99, 8);
s.setToys("Teddy Bear", 33772346,25.99, 6);
s.setToys("Airplane", 44453466,60.99,16);
s.setToys("Doll", 55887896,45.99, 5);
s.setToys("Drone", 99221388, 90.99, 18);
s.setToys("Lego", 88224596, 65.99, 10);
s.display();
cout << endl << "Searching for toys and printing the list with sale price" << endl;
s.find(33772346);
s.find(99221388);
s.find(88224596);
s.display();
}
HOW THE OUTPUT IS SUPPOSED TO LOOK
Printing invalid list of Toys
************************************************************
****Children`s Dream store****
************************************************************
list of the toys
SKU Age Price Sale
Toy[1] :Invalid Toy
Toy[2] :Invalid Toy
Printing valid list of Toys
************************************************************
****Children`s Dream store****
************************************************************
list of the toys
SKU Age Price Sale
Toy[1] :Racing Car 11223344 8 40.99
Toy[2] :Teddy Bear 33772346 6 25.99
Toy[3] :Airplane 44453466 16 60.99
Toy[4] :Doll 55887896 5 45.99
Toy[5] :Drone 99221388 18 90.99
Toy[6] :Lego 88224596 10 65.99
Searching for toys and printing the list with sale price
************************************************************
****Children`s Dream store****
************************************************************
list of the toys
SKU Age Price Sale
Toy[1] :Racing Car 11223344 8 40.99
Toy[2] :Teddy Bear 33772346 6 20.79 On Sale
Toy[3] :Airplane 44453466 16 60.99
Toy[4] :Doll 55887896 5 45.99
Toy[5] :Drone 99221388 18 72.79 On Sale
Toy[6] :Lego 88224596 10 52.79 On Sale
P.S MAKE SURE THERE ARE THESE FILES
Store.cpp
Store.h
Toys.cpp
Toys.h
main.cpp
ONLY THESE LIBRARIES ARE ABLE FOR USE
iostream, cstring, cstdio
DO NOT MODIFY MAIN.CPP AS INSTRUCTED
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr