From cc06e938ac460f6da602f49ac531018a57bcf5ca Mon Sep 17 00:00:00 2001 From: Asheela Magwili Date: Wed, 12 Feb 2020 11:17:00 -0800 Subject: [PATCH 1/4] Doesn't allow sale after 0 amounts of inventory --- Inventory.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Inventory.cpp b/Inventory.cpp index 57964b4..80a36a7 100644 --- a/Inventory.cpp +++ b/Inventory.cpp @@ -4,6 +4,8 @@ using std::string; using std::ostream; +using std::cout; +using std::endl; Inventory::Inventory(string name, float price, int count) { @@ -14,7 +16,16 @@ Inventory::Inventory(string name, float price, int count) void Inventory::sell() { - m_in_stock--; + if(m_in_stock > 0) + { + m_in_stock--; + } + + else + { + cout<<"Sorry, that item is out of stock\n"< Date: Wed, 12 Feb 2020 11:22:55 -0800 Subject: [PATCH 2/4] Documentation is added in-line --- Inventory.cpp | 4 ++++ main.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Inventory.cpp b/Inventory.cpp index 80a36a7..828dff6 100644 --- a/Inventory.cpp +++ b/Inventory.cpp @@ -7,6 +7,7 @@ using std::ostream; using std::cout; using std::endl; +// Inventory class: name of item, price, amount Inventory::Inventory(string name, float price, int count) { m_name = name; @@ -14,13 +15,16 @@ Inventory::Inventory(string name, float price, int count) m_in_stock = count; } +// When user chooses to make a sale void Inventory::sell() { + // Substract one from invetory after a sale. if(m_in_stock > 0) { m_in_stock--; } + // When no inventory is left to sell, send error. else { cout<<"Sorry, that item is out of stock\n"<"; cin>>choice; + // Take user input for Sell until user chooses to Quit if( choice == 'S' || choice == 's' ) { stock.sell(); From 4a9e6cf9aa1ea508af4899d3cb03addad44f80d0 Mon Sep 17 00:00:00 2001 From: Asheela Magwili Date: Wed, 12 Feb 2020 11:28:39 -0800 Subject: [PATCH 3/4] README --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..70fa46b --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +Travis CI Badge: + +[![Build Status](https://travis-ci.com/asheelamagwili/Inventory.svg?branch=master)](https://travis-ci.com/asheelamagwili/Inventory) \ No newline at end of file From da80d6f3665a779ddf1b261a33193546ef3b20fa Mon Sep 17 00:00:00 2001 From: Asheela Magwili Date: Wed, 12 Feb 2020 11:29:52 -0800 Subject: [PATCH 4/4] Travis CI --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1211bb6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: cpp +os: linux +script: + - make \ No newline at end of file