IN3013/INM173 - Object-Oriented Programming in C++
This coursework simulates a simple database operation, and provides practice with strings, streams, vectors and user-defined classes. It is due on Wednesday 12th February, and counts for 8% of the module.
Consider a simple textual table describing the catalogues of retail stores, with a line for each product offered by a store, like
Argos Barbie 6.99
Argos PS2 159.99
Hamleys Barbie 16.99
Each line consists of three words: a vendor code, a product code and
the price of that product from that vendor (a floating point number).
(You may assume that vendor and product codes do not contain spaces.)
The records are not in any special order.
#include <fstream>
...
ifstream in("catalog");
... istream operations ...
The constructor opens the file;
you can then test in to see whether it succeeded.
Barbie 200
PS2 1
Barbie 2
where each line consists of two words:
a product code (as in the catalogue file) and a requested quantity
(a whole number).
Again the lines are in no special order.
For each input line, your program should produce on the standard output a line for each store stocking that product, combining the information from both records. For example, the above inputs might result in
Barbie 200 Argos 6.99
Barbie 200 Hamleys 16.99
PS2 1 Argos 159.99
Barbie 2 Argos 6.99
Barbie 2 Hamleys 16.99
If there are no store records for a particular vendor,
there will be no output for that line.
You may divide the program between additional functions if you wish.
If you wish, you may work on and submit this coursework in pairs. Undeclared pairs will be referred to the academic misconduct procedure - ``We worked together'' will not be an excuse.
A pair should submit a single solution, with both names on it. A pair submission will obtain approximately 95% of the marks that an identical single submission would have obtained, so pairs are expected to do slightly more work than singles:
Barbie 200 Argos 6.99*
Barbie 200 Hamleys 16.99
Argos 1 PS2 159.99*
Barbie 2 Argos 6.99*
Barbie 2 Hamleys 16.99
(if more than one has the lowest price, pick one)
Individuals should not do this extra task.
Submitting as a pair (or a single) for this coursework does not commit you for the remaining courseworks.