Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
text-adventure/Inventory.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
59 lines (56 sloc)
1.08 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class Inventory | |
{ | |
private: | |
int itemNumber; | |
int quantity; | |
double cost; | |
double totalCost; | |
public: | |
Inventory() // declare the Inventory object using the default constructor | |
{ | |
itemNumber = 0; | |
quantity = 0; | |
cost = 0; | |
totalCost = 0; | |
} | |
Inventory(int newItemNumber, int newQuantity, double newCost) | |
{ | |
itemNumber = newItemNumber; | |
quantity = newQuantity; | |
cost = newCost; | |
setTotalCost(quantity, cost); | |
} | |
void setItemNumber(int) | |
{ | |
itemNumber = itemNumber; | |
} | |
void setQuantity(int) | |
{ | |
quantity = quantity; | |
} | |
void setCost(double) | |
{ | |
cost = cost; | |
} | |
void setTotalCost(int, double) | |
{ | |
totalCost = quantity * cost; | |
} | |
int getItemNumber() | |
{ | |
return itemNumber; | |
} | |
int getQuantity() | |
{ | |
return quantity; | |
} | |
double getCost() | |
{ | |
return cost; | |
} | |
double getTotalCost() | |
{ | |
return totalCost; | |
} | |
}; |