Description
Version 3.4.2 (see notes in red)
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 5: THE GOOD HIERARCHY
This milestone creates the Good hierarchy and is the last milestone in the project.
The first step to creating the Good hierarchy is to derive your Good class from your iGood interface. Your Good class is a concrete class that encapsulates information for perishable goods.
Upgrade your Good module to share select functions with the other classes in the hierarchy:
• In the class definition:
o derive Good from interface iGood
o change the prototypes for the following functions to receive a reference to any object in the hierarchy:
bool operator>(const iGood&) const
double operator+=(double&, const iGood&)
std::ostream& operator<<(std::ostream&, const iGood&)
std::istream& operator>>(std::istream&, iGood&)
• In the class implementation:
o change the signatures of these functions to receive a reference to any object in the hierarchy:
bool operator>(const iGood&) const
double operator+=(double&, const iGood&)
std::ostream& operator<<(std::ostream&, const iGood&)
std::istream& operator>>(std::istream&, iGood&)
THE PERISHABLE CLASS
The second step to completing the Good hierarchy is to derive the Perishable class from your Good class. Your Perishable class is a separate concrete class that encapsulates information for perishable goods.
Define and implement your Perishable class in the aid namespace. Store your definition in a header file named Perishable.h and your implementation in a file named Perishable.cpp.
Private data member:
Public member functions:
Your design includes the following public member functions:
• No argument Constructor
This constructor passes the file record tag for a perishable good (‘P’) to the base class constructor and sets the current object to a safe empty state.
• std::fstream& store(std::fstream& file, bool newLine=true) const
This query receives a reference to an fstream object and an optional bool and returns a reference to the modified fstream object. This function stores a single file record for the current object. This function o calls its base class version passing as arguments a reference to the fstream object and a false flag. The base class inserts the common data into the fstream object
o If newLine is false, this function does not insert a newline character (‘ ’) before exiting. In this case, the file record created will look something like:
Note that the first field in the file record is ‘P’. This character was passed to the base class at construction time and is inserted by the base class version of this function.
• std::fstream& load(std::fstream& file)
This modifier receives a reference to an fstream object and returns a reference to that fstream object. This function extracts the data fields for a single file record from the fstream object. This function o calls its base class version passing as an argument a reference to the fstream object
o extracts a single character from the fstream object.
• std::ostream& write(std::ostream& os, bool linear) const
This query receives a reference to an ostream object and a bool flag and returns a reference to the modified ostream object. The flag identifies the output format. This function o calls its base class version passing as arguments a reference to the ostream object and the bool flag.
o if the current object is in an error or safe empty state, does nothing further.
Sku: 1234
Name (no spaces): water
Price: 1.50
Price after tax: N/A
Quantity on hand: 1 liter
Quantity needed: 5
• std::istream& read(std::istream& is)
This modifier receives a reference to an istream object and returns a reference to the modified istream object. This function populates the current object with the data extracted from the istream object.
Note: if you encounter a mismatch between your output and that of the tester program, confirm that your Good::read() function leaves the istream input buffer empty on a reading of the input that generates no errors.
After you have implemented the Perishable class completely, compile your implementation files with the tester files provided. Your implementation files should compile with no error, use your interface and read and append text to the good.txt and goodShortFile.txt files.
The output should look something like this:
–Good test:
—-Taxed validation test:
Enter the following:
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): a
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): a
Passed!
Message should be: Only (Y)es or (N)o are acceptable
Your Error message: Only (Y)es or (N)o are acceptable Press enter to continue …
—-Price validation test:
Enter the following: Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: abc
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: abc
Passed!
Message should be: Invalid Price Entry
Your Error message: Invalid Price Entry Press enter to continue …
—-Quantity validation test:
Enter the following: Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: 10
Quantity on hand: abc
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: 10
Quantity on hand: abc
Passed!
Message should be: Invalid Quantity Entry
Your Error message: Invalid Quantity Entry Press enter to continue …
—-Quantity needed validation test:
Enter the following:
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: 10
Quantity on hand: 10
Quantity needed: abc
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): y
Price: 10
Quantity on hand: 10
Quantity needed: abc
Passed!
Message should be: Invalid Quantity Needed Entry
Your Error message: Invalid Quantity Needed Entry Press enter to continue …
—-Display test, the output of the Program and yours must match:
Enter the following: Sku: 1234
Name (no spaces): box
Unit: kg
Taxed? (y/n): y
Price: 123.45
Quantity on hand: 1
Quantity needed: 5
Sku: 1234
Name (no spaces): box
Unit: kg
Taxed? (y/n): y
Price: 123.45
Quantity on hand: 1
Quantity needed: 5
-Compare the output of the Program and your output:
–Linear————
Program: 1234 |box | 139.50| 1|kg | 5| Yours: 1234 |box | 139.50| 1|kg | 5|
–Form Display——
–Program:
Sku: 1234
Name (no spaces): box
Price : 123.45
Price after tax : 139.50
Quantity on hand : 1 kg Quantity needed : 5
–Yours:
Sku: 1234
Name (no spaces): box
Price: 123.45
Price after tax: 139.50
Quantity on Hand: 1 kg
Quantity needed: 5
Press enter to continue …
—-Storage and loading test, the output of the Program and yours must match:
–Store Good, program:
N,1234,box,kg,1,123.45,1,5
N,1234,box,kg,1,123.45,1,5
–Store Good, yours:
N,1234,box,kg,1,123.45,1,5
N,1234,box,kg,1,123.45,1,5
–Load Good:
Program: 1234 |box | 139.50| 1|kg | 5| Yours: 1234 |box | 139.50| 1|kg | 5|
–Perishable Good test:
Enter the following: Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): n
Price: 10
Quantity on hand: 10
Quantity needed: 10
Sku: abc
Name (no spaces): abc
Unit: abc
Taxed? (y/n): n
Price: 10
Quantity on hand: 10
Quantity needed: 10
Passed!
—-Display test, the output of the Program and yours must match: Enter the following:
Sku: 1234
Name (no spaces): water
Unit: liter
Taxed? (y/n): n
Price: 1.5
Quantity on hand: 1
Quantity needed: 5
Sku: 1234
Name (no spaces): water
Unit: liter
Taxed? (y/n): n
Price: 1.5
Quantity on hand: 1
Quantity needed: 5
-Compare the output of the Program and your output:
–Linear————
–Form Display——
–Program:
Sku: 1234
Name (no spaces): water
Price : 1.50
Price after tax : N/A
Quantity on hand : 1 liter
Quantity needed : 5
–Yours:
Sku: 1234
Name (no spaces): water
Price: 1.50
Price after tax: N/A
Quantity on Hand: 1 liter
Quantity needed: 5
Press enter to continue …
—-Storage and loading test, the output of the Program and yours must match:
–Store Perishable, program:
–Store Perishable, yours:
MILESTONE 5 SUBMISSION
Then run the following command from your account: (replace profname.proflastname with your professors Seneca userid)
~profname.proflastname/submit 244_ms5 <ENTER>
and follow the instructions.
Please note that a successful submission does not guarantee full credit for this workshop.
Reviews
There are no reviews yet.