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
17 changes: 16 additions & 1 deletion Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@

using std::string;
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;
m_price = price;
m_in_stock = count;
}

// When user chooses to make a sale
void Inventory::sell()
{
m_in_stock--;
// 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"<<endl;
}

}

ostream& operator<<(ostream& stream, const Inventory& item)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Travis CI Badge:

[![Build Status](https://travis-ci.com/asheelamagwili/Inventory.svg?branch=master)](https://travis-ci.com/asheelamagwili/Inventory)
2 changes: 2 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ using std::string;
int main()
{
char choice = 'q';
// Initial amount of the stock: Name of stock, price, amount
Inventory stock("Cupcake",2.99,100);

do
{
cout<<"\nMENU\n====\n(S)ell item\n(Q)uit\n>";
cin>>choice;
// Take user input for Sell until user chooses to Quit
if( choice == 'S' || choice == 's' )
{
stock.sell();
Expand Down