//#define CONTROL_EXPIRATION
//#define CONTROL_STORE
//#define CONTROL_RETURN
using namespace std;
struct Product {
char productName[50];
int numberOfProduct;
#ifdef CONTROL_EXPIRATION
char expiry_date[9];
#endif
#ifdef CONTROL_STORE
bool adulterated;
#endif
#ifdef CONTROL_RETURN
bool can_return;
#endif
};
#ifdef CONTROL_EXPIRATION
bool checkExpiration ( char expiry_date[9] ) {
// This function compares vaccine expiration date with current date and
// returns true if the product is expired and false if not.
}
void orderByExpiration ( Product p[4] ) {
// This algorithm sorts the p product array considering the expiration date.
// At the end of the algorithm, the product with the earliest expiration date will be the first element of the array
// and the product with the most distant expiration date will be the last element.
}
#endif
void discardProduct( Product p[4] ) {
#ifdef CONTROL_EXPIRATION
orderByExpiration ();
#endif
int i, n = 4;
int numberOfDiscardedProducts = 0;
int numberOfReturnedProducts = 0;
for ( i = 0; i < n; i ++ ) {
printf ( "\n Product name: %s " , p[i].productName );
printf ( "\n Number of product: %d " , p[i].numberOfProduct );
#ifdef CONTROL_STORE
if ( p[i].adulterated ) {
#endif
numberOfDiscardedProducts += p[i].numberOfProduct;
#ifdef CONTROL_EXPIRATION
if ( checkExpiration( p[i].expiry_date ) ) {
#endif
#ifdef CONTROL_RETURN
if ( p[i].can_return ) {
numberOfReturnedProducts += p[i].numberOfProduct;
numberOfDiscardedProducts -= p[i].numberOfProduct;
printf ( "\n Product returned" );
} else
#endif
printf ( "\n Product discarded" );
#ifdef CONTROL_EXPIRATION
}
#endif
#ifdef CONTROL_STORE
}
#endif
}
printf ( "\n Number of Discarded Products: %d " , numberOfDiscardedProducts);
printf ( "\n Number of returned products: %d " , numberOfReturnedProducts);
}
int main(){
Product p[4] = { {"Drug A", 50},
{"Drug C", 150},
{"Drug B", 100},
{"Drug D", 200} };
discardProduct ( p );
return 0;
}