Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<string.h>
- #include<stdlib.h>
- using namespace std;
- //set chars to 0 name i drugite
- void HistorySheet(char hist[][100],char todayDate[],char given_name[],char amount[],int sizeHint,int status);
- class Storage{
- private:
- char savedata[100][100];
- ;
- int n;
- int total;
- int helpArray[100];
- int choice;
- int choiceAction;
- char todayDate[15];
- int sizeHint;
- char name [16];
- char amount[15];
- char searchname[16];
- int clean_name;
- int clean_amount;
- char producer [16];
- char type[5];
- int quantity;
- int location;
- int element[200];
- char given_name[16];
- int given_day;
- int given_month;
- int given_year;
- int expiration_year;
- int expiration_month;
- int expiration_day;
- int entrance_day;
- int entrance_month;
- int entrance_year;
- int given_entrance_day;
- int given_entrance_month;
- int given_entrance_year;
- char given_producer[16];
- char given_type[5];
- int given_quantity;
- public :
- friend void HistorySheet(char hist[][100],char todayDate,char given_name,string amount,int sizeHint);
- friend void PrintHistory(char hist[][100],int n,int j);
- friend void information(Storage product [],int i);
- friend void cleaner (Storage product [],int i);
- friend void manycleaner(char a[][16],Storage product [],int i,string amount,int cleanamount);
- friend void asker(Storage product[],int size);
- Storage(){
- sizeHint=0;
- }
- void Set_name(char given_name[])
- {
- strcpy(name,given_name);
- }
- char * Get_name ()
- {
- return name;
- }
- void Set_expiration_day(char given_day[])
- {
- expiration_day=atoi(given_day);
- }
- int Get_expiration_day ( ){
- return expiration_day;
- }
- void Set_expiration_month(int given_month)
- {
- expiration_month=given_month;
- }
- int Get_expiration_month( ){
- return expiration_month;
- }
- void Set_expiration_year(int given_year)
- {
- expiration_year=given_year;
- }
- int Get_expiration_year( ){
- return expiration_year;
- }
- void Set_entrance_day(int given_entrance_day)
- {
- entrance_day=given_entrance_day;
- }
- int Get_entrance_day ( ){
- return entrance_day;
- }
- void Set_entrance_month(int given_entrance_month)
- {
- entrance_month=given_entrance_month;
- }
- int Get_entrance_month( ){
- return entrance_month;
- }
- void Set_entrance_year(int given_year)
- {
- entrance_month=given_month;
- }
- int Get_entrance_year( ){
- return entrance_year;
- }
- void Set_producer(char given_producer[])
- {
- strcpy(producer,given_producer);
- }
- char * Get_producer()
- {
- return producer;
- }
- void Set_type(char given_type[])
- {
- strcpy(type,given_type);
- }
- char * Get_type(){
- return type;
- }
- void Set_quantity(int given_quantity)
- {
- quantity=given_quantity;
- }
- int Get_quantity()
- {
- return quantity;
- }
- };
- void Store:: HistorySheet(char given_name[],char amount[],int status)
- {
- sizeHint++;
- strcat(hist[sizeHint] ,todayDate);
- strcat(hist[sizeHint],"/");
- strcat(hist[sizeHint],given_name);
- strcat(hist[sizeHint],"/");
- strcat(hist[sizeHint],amount);
- }
- void Store ::PrintHistory(int n,int j)
- {
- for (int i=0;i<n;i++)
- {
- for (int j=0;j<20;j++)
- {
- cout<<hist[i][j];
- }
- cout<<endl;
- }
- }
- void Store::information(int i)
- {
- cout<<"The name of the product is";
- product[i].Get_name();
- cout<<"The expiration date is "<<product[i].Get_expiration_day()<<'/'<<product[i].Get_expiration_month()<<'/'<<product[i].Get_expiration_year();
- cout<<"The entrance day is "<<product[i].Get_entrance_day()<<'/'<<product[i].Get_entrance_month()<<'/'<<product[i].Get_entrance_year();
- cout<<"The name of the producer is"<<product[i].Get_producer();
- cout<<"The quantitiy is "<<product[i].Get_quantity();
- cout<<"The location is "<<i;
- }
- void Store:: cleaner (int i)
- {
- product[i].Set_name("");
- product[i].Set_expiration_day("");
- product[i].Set_expiration_month("");
- product[i].Set_expiration_year("");
- product[i].Set_entrance_day("");
- product[i].Set_entrance_month("");
- product[i].Set_producer("");
- product[i].Set_quantity("");
- }
- void Store ::manycleaner(int i,string amount,int clean_amount)
- {
- char clean_name[15];
- string amount;
- int clear_amount;
- cout<<"Enter how many products";
- cin>>amount;
- for (int i=1;i<=amount;i++){
- cout<<"Enter the name of the product and then the amount";
- cin>>clean_name;
- for (int j=0;j<n;j++)
- {
- if (strcmp(clean_name,product[j].Get_name())==0)
- {
- cin>>clean_amount;
- if (product[a[t]].Get_quantity()<clean_amount)
- {
- cout<<"You've entered more than the available quantity";
- cout<<"Quantity in storage:"<<product[a[t]].Get_quantity();
- HistorySheet(hist,given_today,product[a[t]].Get-quantity(),100,0);
- cout<<"Do you want to remove everything?Press 1 for yes ";
- cin>>choice;
- if (choice==1)
- { cout<<"Here is the info for the element you just removed";
- information (a[t]);
- HistorySheet(product[i].Get_name,amount,0);
- cleaner(a[t]);
- }
- else
- {
- continue;
- }
- }
- }
- }
- }
- }
- void Store:: asker()
- {
- char given_name[15];
- int given_month;
- int given_day;
- int given_year;
- int given_quantity;
- char given_producer[15];
- char type[15];
- char given_type[15];
- for (int i=1;i<=size;i++)
- {
- cout<<"Enter the name of the product";
- cin>>given_name;
- if (strlen(given_name)>15)
- {
- cout<<"The name is too long";
- }
- else
- {
- product[i].Set_name(given_name);
- }
- cout<<"Enter the expiration date-month";
- cin>>given_month;
- if(given_month>0 && given_month<=12)
- {
- product[i].Set_expiration_month(given_month);
- }
- else
- {
- cout<<"wrong input for month";
- }
- cout<<"Enter the expiration day";
- cin>>given_day;
- if(given_day==28 && product[i].expiration_month==2)
- {
- product[i].Set_expiration_day(given_day);
- }
- else if (given_day>0 && given_day<31 &&product[i].expiration_month==1,3,5,7,8,10,12)
- {
- product[i].Set_expiration_day(given_day);
- }
- else if ( given_day>0 && given_day <30 )
- {
- product[i].Set_expiration_day(given_day);
- }
- cout<<"Enter expiration year";
- cin>>given_year;
- if ( given_year>0 && given_year<2016)
- {
- product[i].Set_expiration_year(given_year);
- }
- else
- {
- cout<<"wrong input";
- }
- cout<<"Enter the name of the producer between 1 and 15 characters";
- cin>>given_producer;
- if (strlen(given_producer)>0 && strlen(given_producer)<16 )
- {
- product[i].Set_producer(given_producer);
- }
- else{
- cout<<"wrong input";
- }
- cout<<"Enter 'l' for liters or 'kg' for kilograms";
- cin>>given_type;
- if (strcmp(given_type,'kg')==0 || strcmp(given_type,'l')==0)
- {
- product[i].Set_type(given_type);
- }
- else
- {
- cout<<"wrong output";
- }
- cout<<"Now enter the quantity in integers of the product";
- cin>>given_quantity;
- if (given_quantity>0 && given_quantity<=1000)
- {
- product[i].Set_quantity(given_quantity);
- }
- else
- {
- cout<<"wrong input";
- }
- }
- }
- class Store{
- private:
- Storage * product;
- int sizeHint;
- char hist[200][200];
- char a[100][16];
- char todayDate [15];
- int size;
- public:
- Store(int);
- void HistorySheet(char given_name[],char amount[],int status);
- void manycleaner(int i,string amount,int cleanamount);
- void asker();
- void PrintHistory(int n,int j);
- void information(int i);
- void cleaner (int i);
- };
- Store::Store(int n){
- sizeHint=0;
- product=new Storage[n];
- size=n;
- }
- int main()
- {
- int choice;
- while(true){
- cin>>choice
- switch (choice)
- {
- case 1:asker();
- case 2://do something
- case 3:return 0; //which will exith the program
- default:
- break;
- }
- }
- int n ;
- cout<<"How many products you want ";
- cin>>n;
- char todayDate[15];
- Store s(n);
- s.asker();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement