Advertisement
deen_5_98

Untitled

Jun 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include "InvClass.h"
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.     InvClass item1("Hammer", 6.95, 12);
  9.     //item1.setDescription("Hammer", 6.95, 12);
  10.     // item1.setCost(6.95);
  11.     // item1.setUnits(12);
  12.  
  13.     InvClass item2 ("pliers");
  14.     // item2.setDescription("Pliers");
  15.  
  16.     InvClass item3("Wrench", 8.75, 20);
  17.     // item3.setDescription("wrench");
  18.     // item3.setCost(8.75);
  19.     // item3.setUnits(20);
  20.     cout << "The following items are in the inventory: \n" << endl;
  21.     cout << setprecision(2) << fixed << showpoint;
  22.  
  23.     cout << "Description: " << item1.getDescription() << endl;
  24.     cout << "Cost: " << item1.getCost() << endl;
  25.     cout << "Units: " << item1.getUnits() << endl;
  26.  
  27.     cout << "Description: " << item2.getDescription() << endl;
  28.     cout << "Cost: " << item2.getCost() << endl;
  29.     cout << "Units: " << item2.getUnits() << endl;
  30.  
  31.     cout << "Description: " << item3.getDescription() << endl;
  32.     cout << "Cost: " << item3.getCost() << endl;
  33.     cout << "Units: " << item3.getUnits() << endl;
  34.  
  35.  
  36.     return 0;
  37.     }
  38.  
  39.  
  40. // /\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\
  41. #include "InvClass.h"
  42.   InvClass::InvClass(){
  43.             description = "";
  44.             cost = 0.0;
  45.             units = 0;
  46.  
  47.         }
  48.   InvClass::InvClass(string desc){
  49.  
  50.             description = desc;
  51.             cost = 0.0;
  52.             units = 0;
  53.  
  54.         }
  55.          InvClass::InvClass(string desc, double c, int u){
  56.  
  57.             description = desc;
  58.             cost = 0.0;
  59.             units = 0;
  60.  
  61.         }
  62.           void InvClass::setDescription(string d){
  63.  
  64.             description = d;
  65.         }
  66.  
  67.         void InvClass::setCost(double c){
  68.  
  69.             cost = c;
  70.         }
  71.  
  72.         void InvClass::setUnits(int u){
  73.  
  74.             units = u;
  75.         }
  76.  
  77.         string InvClass::getDescription(){
  78.  
  79.             return description;
  80.         }
  81.  
  82.         double InvClass::getCost(){
  83.  
  84.             return cost;
  85.         }
  86.  
  87.         int InvClass::getUnits(){
  88.  
  89.             return units;
  90.         }
  91.  
  92. // /\/\/\/\//\/\/\/\/\/\\//\\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  93. #ifndef INVCLASS_H
  94. #define INVCLASS_H
  95.  
  96.  
  97. // used inline declaration because there not much declaraion
  98.  
  99. #include <string>
  100.  
  101. using namespace std;
  102.  
  103. class InvClass{
  104.     private:
  105.         string description;
  106.         double cost;
  107.         int units;
  108.     public:
  109.         InvClass();
  110.         InvClass(string desc);
  111.         InvClass(string desc, double c, int u);
  112.  
  113.         void setDescription(string d);
  114.         void setCost(double c);
  115.         void setUnits(int u);
  116.         string getDescription();
  117.         double getCost();
  118.         int getUnits();
  119. };
  120.  
  121.  
  122.  
  123. #endif // INVCLASS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement