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.01 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 itemID; | |
int amount; | |
double cost; | |
double totalCost; | |
public: | |
Inventory() // declare the Inventory object using the constructor | |
{ | |
itemID = 0; | |
amount = 0; | |
cost = 0; | |
totalCost = 0; | |
} | |
Inventory(int newItemID, int newamount, double newCost) | |
{ | |
itemID = newItemID; | |
amount = newamount; | |
cost = newCost; | |
setTotalCost(amount, cost); | |
} | |
void setItemID(int) | |
{ | |
itemID = itemID; | |
} | |
void setamount(int) | |
{ | |
amount = amount; | |
} | |
void setCost(double) | |
{ | |
cost = cost; | |
} | |
void setTotalCost(int, double) | |
{ | |
totalCost = amount * cost; | |
} | |
int getItemID() | |
{ | |
return itemID; | |
} | |
int getQuantity() | |
{ | |
return amount; | |
} | |
double getCost() | |
{ | |
return cost; | |
} | |
double getTotalCost() | |
{ | |
return totalCost; | |
} | |
}; |