Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following paragraph in English and then consider the following code that expresses the same concepts in C++. An item has a name, a

image text in transcribedimage text in transcribed

Consider the following paragraph in English and then consider the following code that expresses the same concepts in C++. An item has a name, a price, and an expiry date. A store item is an item that has the number of available items in the store. A monetary bill has a value and a unit; e.g. 1,000 L.L. For simplicity we consider coins to be bills as well. A basket has a sequence of items. A customer has a basket and only one bill of cash to pay for the basket. A cash register has monetary bills each associated with a number of bills. Each cash register has also a set of customers waiting to be served. A store has a set of store items and a set of cash registers. I/a date tuple has a day, month and year values. struct dater (unsigned int day, month, year;); // an item has a name, a price, an expiry date, and a number of items available struct itemt (string name; double price; datet expiry :); //a store item is an item, it has the number of available items struct storeItemt : public itemt { unsigned int available;); //a bill has a value and a unit struct billt (unsigned int value; string unit:): // a basket has items struct basketT (vector items; }; //a customer has a basket and one bill of cash struct customerT {basket T b; billy cash;}; I/a register has drawers for bills and a count for each bill struct registert {vector bills; vector (unsigned int > count; vector customerT> customers :); //astore has a sett of items and a set of registers struct storet ( vector items; vector registers;}; Notice the basic structure of the English sentences and how all "noun" concepts were translated into structures, objects, sets of objects, and relations between objects. The "has verb occurrences translate into data members denoting an "ownership" relation between the two objects. The "is" verb occurrences translates to an inheritance relation indicating an identity or a subset relation. You will exercise the same translation in the next problem. Add methods (functions) to the classes to perform the following actions (verbs). The basket is smart. It computes the total price of its items. So develop a method double getTotal() const in class baskets that computes and returns the total price of all its items. The register handles one customer at a time using method (handleCustomer(customett & cu)). It takes as input a customer from the set of customers, checks the total for the basket of the customer, checks whether the bill with the customer is enough to pay for the basket. If all checks pass, then the method adds the bill from the customer to the register and returns to the customer the minimum number of bills. advice: you can split this into more than one function. hint: you might want to sort some of the vectors you have for an efficient solution. OPTIONAL: The store runs its business as follows. It iterates over all its registers, and once a register handles a customer successfully, it updates the store items by removing the corresponding basket items. think of a fast search to match the items of the basket with the items of the store. In case the count of a store item drops below 5, the program outputs a list of requests to refill the inventory. Write a main function to test your program one method at a time. You may want to use srand d rand to reduce the time you need for data entry

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Are Social Security benefits tax free? Explain.

Answered: 1 week ago

Question

What is the nature and type of each key public?

Answered: 1 week ago