diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5cf7002 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: cpp +os: linux +script: + - g++ *.cpp diff --git a/Inventory.cpp b/Inventory.cpp index de8e7b8..122e60d 100644 --- a/Inventory.cpp +++ b/Inventory.cpp @@ -4,7 +4,7 @@ using std::string; using std::ostream; - + Inventory::Inventory(string name, float price, int count) { m_name = name; @@ -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; -} \ No newline at end of file + +} +return stream; +} diff --git a/Inventory.h b/Inventory.h index c52d5d8..0531177 100644 --- a/Inventory.h +++ b/Inventory.h @@ -18,4 +18,4 @@ class Inventory friend ostream& operator<<(ostream&, const Inventory&); }; -#endif \ No newline at end of file +#endif diff --git a/README.md b/README.md new file mode 100644 index 0000000..a8e829d --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +[![Build Status](https://travis-ci.com/adhaar-star/Inventory.svg?branch=master)](https://travis-ci.com/adhaar-star/Inventory) diff --git a/a.out b/a.out new file mode 100755 index 0000000..168b967 Binary files /dev/null and b/a.out differ diff --git a/main.cpp b/main.cpp index 08d69fc..2ab6338 100644 --- a/main.cpp +++ b/main.cpp @@ -26,4 +26,4 @@ int main() }while( choice != 'q' && choice != 'Q'); return 0; -} \ No newline at end of file +}