Description
Version 3.4
When disaster hits a populated area, the most critical task is to provide immediately affected people with what they need as quickly and as efficiently as possible.
This project creates an application that manages the list of goods that need to be shipped to ae disaster area. The application tracks the quantity of items needed, tracks the quantity on hand, and stores the information in a file for future use.
There are two categories for the types of goods that need to be shipped:
To complete this project you will need to create several classes that encapsulate your solution.
OVERVIEW OF THE CLASSES TO BE DEVELOPED
The classes used by the application are:
Error
Good
A class that manages a non-perishable good object.
Perishable
iGood
An interface to the Good hierarchy. This interface exposes the features of the hierarchy available to the application. Any “iGood” class can
• read itself from the console or write itself to the console
• save itself to a text file or load itself from a text file
• compare itself to a unique C-style string identifier
• determine if it is greater than another good in the collating sequence
• report the total cost of the items on hand
• describe itself
• update the quantity of the items on hand
• report its quantity of the items on hand
• report the quantity of items needed
• accept a number of items
Using this class, the client application can
• save its set of iGoods to a file and retrieve that set at a later time
• read individual item specifications from the keyboard and display them on the screen
• update information regarding the number of each good on hand
THE CLIENT APPLICATION
The client application manages the iGoods and provides the user with options to
• list the Goods
• display details of a Good
• add a Good
• add items of a Good
• update the items of a Good
• delete a Good
• sort the set of Goods
PROJECT CLASS DIAGRAM
PROJECT DEVELOPMENT PROCESS
In order to earn credit for the whole project, you must complete all milestones and assemble them for the final submission.
FILE STRUCTURE OF THE PROJECT
Each class belongs to its own module. Each module has its own header (.h) file and its own implementation (.cpp) file. The name of each file without the extension is the name of its class.
All the code developed for this application belongs to the aid namespace.
MILESTONE 4: THE IGOOD INTERFACE
The iGood class is an interface that exposes the Good hierarchy to client applications. This class is abstract and cannot be instantiated. You will add and develop concrete classes of the hierarchy in the following milestone.
Save your definition of the iGood interface in a header file named iGood.h.
The definition of your iGood interface includes the following pure virtual member functions:
• std::fstream& store(std::fstream& file, bool newLine=true) const
This query will receive a reference to an std::fstream object and an optional bool and return a reference to the std::fstream object. The bool argument will specify whether or not a newline should be inserted after each iGood record. Implementations of this function will insert the Good records into the std::fstream object.
• std::fstream& load(std::fstream& file)
This modifier will receive a reference to an std::fstream object and return a reference to that std::fstream object. Implementations of this function will extract iGood records from the std::fstream object.
• std::ostream& write(std::ostream& os, bool linear) const
This query will receive a reference to an std::ostream object and a bool and return a reference to the std::ostream object. The bool argument will specify whether or not the records should be listed on a single line or on separate lines. Implementations of this function will insert the iGood record for the current object into the std::ostream object.
• std::istream& read(std::istream& is)
This modifier will receive a reference to an std::istream object and returns a reference to the std::istream object. Implementations of this function will extract the iGood record for the current object from the std::istream object.
• bool operator==(const char*) const
This query will receive the address of an unmodifiable C-style null-terminated string and return true if the string is identical to the stock keeping unit of an iGood record; false otherwise.
• double total_cost() const
This query will return the cost of a single unit of an iGood with taxes included.
• const char* name() const
This query will return the address of a C-style null-terminated string containing the name of an iGood.
• void quantity(int)
This modifier will receive an integer holding the number of units of an iGood that are currently available. This function will set the number of units available.
• int qtyNeeded() const
This query will return the number of units of an iGood that are needed.
• int quantity() const
This query will return the number of units of an iGood that are currently available.
• int operator+=(int)
This modifier will receive an integer identifying the number of units to be added to the iGood and return the updated number of units currently available.
• bool operator>(const iGood&) const
This query will receive an unmodifiable reference to an iGood object and return true if the current object is greater than the referenced iGood object; false otherwise.
The following helper functions support your interface:
• std::ostream& operator<<(std::ostream&, const iGood&)
This helper function will receive a reference to an std::ostream object and an unmodifiable reference to an iGood object and return a reference to the std::ostream object. Implementations of this function will insert the iGood record for the referenced object into the ostream object.
• std::istream& operator>>(std::istream&, iGood&)
This helper function will receive a reference to an std::istream object and a reference to an iGood object and return a reference to the std::istream object.
Implementations of this function will extract the iGood record for the referenced object from the std::istream object.
• double operator+=(double&, const iGood&)
This helper function will receive a reference to a double and an unmodifiable reference to an iGood object and return a double. Implementations of this function will add the total cost of the iGood object to the double received and return the updated value of the double.
• iGood* CreateGood()
This helper function will return the address of a Good object.
• iGood* CreatePerishable()
This helper function will return the address of a Perishable object.
Once you have defined this interface, compile the tester files provided on Visual Studio. These files should compile without error. The executable code should use your interface to append data fields to and read data fields from the ms4.txt file.
MILESTONE 4 SUBMISSION
Upload iGood.h and the tester files to your matrix account. Compile and rerun your code and make sure everything works properly.
Then run the following command from your account: (replace profname.proflastname with your professor’s Seneca userid)
~profname.proflastname/submit 244_ms4 <ENTER>
and follow the instructions.
Please note that a successful submission does not guarantee full credit for this milestone.
Reviews
There are no reviews yet.