I am trying to get this output.
1 2 3 4
|
Product Name: Orange
Reference Number: 1123456
Price per unit/pound: 0.99
Stock: 34
|
With this code:
#include <string>
#include <iostream>
using namespace std;
class Product {
private:
string prodName;
double price;
unsigned refNum, items_remaining;
public:
Product (){
refNum=items_remaining=0; price=0; prodName="";
}
Product ( string prod, unsigned ref, double pri, unsigned stk){
refNum = ref;
items_remaining = stk;
prodName = prod;
price = pri;
}
//Add Accessors
string get_name(string name){
cin>>name;
return prodName;
}
double get_price (double cost){
cin>>cost;
return price;
}
unsigned stock (unsigned items){
cin>>items;
return items_remaining;
}
unsigned sold (unsigned items_remaining, unsigned num_sold){
items_remaining -= num_sold;
return items_remaining;
}
unsigned addToStock (unsigned items_remaining, unsigned stock_add){
stock_add +=items_remaining;
return items_remaining;
}
void info (){
cout<<"Product Name: "<<prodName<<endl;
cout<<"Reference Num: "<<refNum<<endl;
cout<<"Price per unit/pound: "<<price<<endl;
cout<<"Stock: "<<items_remaining<<endl;
}
};