Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: cpp
os: linux
script:
- make
13 changes: 12 additions & 1 deletion Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@
using std::string;
using std::ostream;

/*Constructor for an Inventory object*/
Inventory::Inventory(string name, float price, int count)
{
m_name = name;
m_price = price;
m_in_stock = count;
}

/*Checking if an item is an stock and making a sale
*ultimately decreasing stock.
*/

void Inventory::sell()
{
if(m_in_stock == 0){
std::cout<<"Sorry, that item is out of stock"<<std::endl;
}
else{
m_in_stock--;
}
}

/*Transaction statement*/
ostream& operator<<(ostream& stream, const Inventory& item)
{
stream << item.m_name
<< " $"
<< std::fixed << std::setprecision(2) << item.m_price;
return stream;
}
}
10 changes: 9 additions & 1 deletion Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
using std::string;
using std::ostream;

/*
* This class represents an Invetory of a shop
* Inventory holds
* -the name of an item
* -the price and
* -how much is left in stock
*/

class Inventory
{
private:
Expand All @@ -18,4 +26,4 @@ class Inventory
friend ostream& operator<<(ostream&, const Inventory&);
};

#endif
#endif
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To build: type make into the command line

to run type ./a.out