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:
- g++ *.cpp
15 changes: 12 additions & 3 deletions Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using std::string;
using std::ostream;

Inventory::Inventory(string name, float price, int count)
{
m_name = name;
Expand All @@ -14,12 +14,21 @@ Inventory::Inventory(string name, float price, int count)

void Inventory::sell()
{
if(m_in_stock>0){
m_in_stock--;
}
}

ostream& operator<<(ostream& stream, const Inventory& item)
{
if(item.m_in_stock==0){
stream << "Sorry, that item is out of stock";
}
else{

stream << item.m_name << " $"
<< std::fixed << std::setprecision(2) << item.m_price;
return stream;
}

}
return stream;
}
2 changes: 1 addition & 1 deletion Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class Inventory
friend ostream& operator<<(ostream&, const Inventory&);
};

#endif
#endif
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Build Status](https://travis-ci.com/adhaar-star/Inventory.svg?branch=master)](https://travis-ci.com/adhaar-star/Inventory)
Binary file added a.out
Binary file not shown.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ int main()
}while( choice != 'q' && choice != 'Q');

return 0;
}
}