In this project you are to construct a simple Auto Parts database. In order to make it simple we will keep the parts in an array. Each part is defined by a part class and the Data Base is also a Class. If you see a problem with the specification it is you responsibility to bring it to my attention quickly. Use the Visual Studio support to add these classes as discussed in class.
Each part has a Name of type string, a 9 digit ID number of type string, a weight of type double, maximum in-store count of type int and an actual in-store count of type int. These should all be private. The class that defines this type should also include a parameterized constructor.
Part Class Specification
_name : string // Name of part
_ID : string // ID of part eg 132436353
_weight : double // eg 23.4 oz
_count : integer // 10 items in store
_maxCount: integer // Store has room for 15 parts of this type
Part(name,id,wt,ct,max) // constructor
~Part() // destructor is not used in this project
string GetID() // returns the 9 digit ID string
string GetName() // returns the name of this part
double GetWeight() //returns the weight
int GetCount() // returns the in-store count.
void SetCount(int i) // update count << -- modified 9/20/2017
int GetMax() // returns the maximum number of parts for this part
void AddToInv(int i) // Add i parts to this parts inventory ie update _count
void RemoveFromInv(int i) // remove i parts from this parts inventory ie update _count
This class encapsulates an array of Parts. This is basically an inventory of all the car parts in the store. You can set the array size to 1000 for this project since the number of parts kept at the store is less than 1000.
PartBase Class specification
_partList:Part // array of a maximum of 10 parts
_size : integer // number of different part types in DB
int AddNewPart(Part p) // adds NEW part type to inventory, inc size
// returns -1 if database full, -2 if part
// already in database. Do nothing in this case
int AddToInv(PartID, i) // add i to part count, ie AddToInv(), return <<- modified 9/19/17
// -1 if part p is not in database. return -2
// if i+_count>_maxCount. Do nothing
int Sell(PartID, i) // sell i copies of Part PartID. ie RemoveFromInv(), return <<-Modified
// -1 if part p is not in database. If there are
// not enough parts to fill order return -2 ,do
// not update part p.
int GetPartCt(PartID) // return the number of parts of type p on the shelf <<-Modified
// return -1 if part is not in database
double GetWeightOfDB() // return the total weight of the database
void Print() // prints the parts in database using format below
You project is to implement the above two classes and then write a main program that reads in and processes a list of transactions. There are 4 types of transactions( AddPart, Sell, AddToInv and Print) The format of these transactions are shown in the example below. When a transaction is properly performed you should print the following for each type.
- AddPart :: New Part name (ID) added to inventory
- Sell :: Sold ct name (ID) parts, # parts left
- AddToInv:: ct new name(ID) parts added to inventory, # parts available
- Print:: each line should have this format -> Fuel_Pump 234343213 123.4 5 5 with weight and total part count added at the end
If there is an error in the transaction then print the error as follows
- AddPart :: Error:DataBase Full or Error:Part ID is already in DataBase
- Sell :: Error:Not enough name(ID) parts available or Error:Part name(ID) not in DataBase on Sell
- AddToInv:: Error:No room available for part name(ID) or Error:Part name(ID) not in DataBase on AddToInv
- Print:: This should work
AddPart Fuel_Pump 234343213 123.4 5 5 //adds new part to db
AddPart Hose 344343223 23.4 4 10
AddPart Hose 123243543 18.5 2 5
AddPart Water_Pump 44300223 23.4 2 4
AddPart Antifreeze 545343211 23.4 3 5
Sell 344343223 1 // updates this parts _count
Sell 44300223 2
AddToInv 545343211 2 // updates this parts _count
Sell 44300223 1 // no more parts
Print // print out the database. the last
// line should be Total Weight = #, Total Part count = #
In developing this project you need to create a lot more transactions to test your cde. Be sure and create transactions that will create all the possible errors. I will give you the required transaction data a couple days before it is due so test carefully. Also document as I have requested. See program documentation and submission format a the top of this page.