📄 product.h
字号:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Product
{
public:
/*
Constructs a product with a given name, price and quantity
@param n the product name
@param p the price
@param q the quantity
*/
Product(string n, double p, int q);
/*
Gets the product name
@return the name
*/
string get_name() const;
/*
Gets the product price
@return the price
*/
double get_price() const;
/*
Gets the product quantity
@return the quantity
*/
int get_quantity() const;
/*
Adds to the product quantity
@param amount the amount to add
*/
void add_quantity(int amount);
private:
string name;
double price;
int quantity;
};
Product::Product(string n, double p, int q)
{
name = n;
price = p;
quantity = q;
}
string Product::get_name() const
{
return name;
}
double Product::get_price() const
{
return price;
}
int Product::get_quantity() const
{
return quantity;
}
void Product::add_quantity(int amount)
{
quantity = quantity + amount;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -