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++ -std=c++11 -Wfatal-errors *.cpp
12 changes: 10 additions & 2 deletions Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
using std::string;
using std::ostream;


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

// Inventory method that decrements stocks when it is sold
// or prints sold out if there is none.
void Inventory::sell()
{
m_in_stock--;
if(m_in_stock > 0)
m_in_stock--;
else
std::cout << "Sorry, that item is out of stock" << std::endl;
}

// Prints name and price
ostream& operator<<(ostream& stream, const Inventory& item)
{
stream << item.m_name
<< " $"
<< std::fixed << std::setprecision(2) << item.m_price;
return stream;
}
}
2 changes: 2 additions & 0 deletions Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using std::string;
using std::ostream;

// Inventory class that stores name, price, and in_stock variables.
// Has funtions that decrement in_stock when it is sold.
class Inventory
{
private:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[![Build Status](https://travis-ci.org/jcheon/Inventory.svg?branch=master)](https://travis-ci.org/jcheon/Inventory)

# Inventory

# Get started
- To begin, grab the repo into your machine.
- cd into the repo.
- type 'make' to make an executable
- give inputs 'S' (sell) or 'Q'(quit)