Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include "InvClass.h"
- using namespace std;
- int main(){
- InvClass item1("Hammer", 6.95, 12);
- //item1.setDescription("Hammer", 6.95, 12);
- // item1.setCost(6.95);
- // item1.setUnits(12);
- InvClass item2 ("pliers");
- // item2.setDescription("Pliers");
- InvClass item3("Wrench", 8.75, 20);
- // item3.setDescription("wrench");
- // item3.setCost(8.75);
- // item3.setUnits(20);
- cout << "The following items are in the inventory: \n" << endl;
- cout << setprecision(2) << fixed << showpoint;
- cout << "Description: " << item1.getDescription() << endl;
- cout << "Cost: " << item1.getCost() << endl;
- cout << "Units: " << item1.getUnits() << endl;
- cout << "Description: " << item2.getDescription() << endl;
- cout << "Cost: " << item2.getCost() << endl;
- cout << "Units: " << item2.getUnits() << endl;
- cout << "Description: " << item3.getDescription() << endl;
- cout << "Cost: " << item3.getCost() << endl;
- cout << "Units: " << item3.getUnits() << endl;
- return 0;
- }
- // /\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\
- #include "InvClass.h"
- InvClass::InvClass(){
- description = "";
- cost = 0.0;
- units = 0;
- }
- InvClass::InvClass(string desc){
- description = desc;
- cost = 0.0;
- units = 0;
- }
- InvClass::InvClass(string desc, double c, int u){
- description = desc;
- cost = 0.0;
- units = 0;
- }
- void InvClass::setDescription(string d){
- description = d;
- }
- void InvClass::setCost(double c){
- cost = c;
- }
- void InvClass::setUnits(int u){
- units = u;
- }
- string InvClass::getDescription(){
- return description;
- }
- double InvClass::getCost(){
- return cost;
- }
- int InvClass::getUnits(){
- return units;
- }
- // /\/\/\/\//\/\/\/\/\/\\//\\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- #ifndef INVCLASS_H
- #define INVCLASS_H
- // used inline declaration because there not much declaraion
- #include <string>
- using namespace std;
- class InvClass{
- private:
- string description;
- double cost;
- int units;
- public:
- InvClass();
- InvClass(string desc);
- InvClass(string desc, double c, int u);
- void setDescription(string d);
- void setCost(double c);
- void setUnits(int u);
- string getDescription();
- double getCost();
- int getUnits();
- };
- #endif // INVCLASS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement