structure, layout, parser and its modules
This commit is contained in:
26
goods/goods.cpp
Normal file
26
goods/goods.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "goods.h"
|
||||
#include <string>
|
||||
|
||||
Goods::Goods(std::string name, double quantity, double price_per_unit) {
|
||||
this->name = name;
|
||||
this->quantity = quantity;
|
||||
this->price_per_unit = price_per_unit;
|
||||
}
|
||||
|
||||
double Goods::calculate_total_price() {
|
||||
return this->price_per_unit * this->quantity;
|
||||
}
|
||||
|
||||
std::string Goods::get_name() { return this->name; }
|
||||
|
||||
double Goods::get_quantity() { return this->quantity; }
|
||||
|
||||
double Goods::get_price_per_unit() { return this->price_per_unit; }
|
||||
|
||||
void Goods::set_name(std::string name) { this->name = name; }
|
||||
|
||||
void Goods::set_quantity(double quantity) { this->quantity = quantity; }
|
||||
|
||||
void Goods::set_price_per_unit(double price_per_unit) {
|
||||
this->price_per_unit = price_per_unit;
|
||||
}
|
||||
24
goods/goods.h
Normal file
24
goods/goods.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef GOODS_H
|
||||
#define GOODS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class Goods
|
||||
{
|
||||
std::string name;
|
||||
double quantity; // by weight or by the piece
|
||||
double price_per_unit;
|
||||
public:
|
||||
Goods(std::string, double, double);
|
||||
double calculate_total_price();
|
||||
|
||||
std::string get_name();
|
||||
double get_quantity();
|
||||
double get_price_per_unit();
|
||||
|
||||
void set_name(std::string);
|
||||
void set_quantity(double);
|
||||
void set_price_per_unit(double);
|
||||
};
|
||||
|
||||
#endif // GOODS_H
|
||||
Reference in New Issue
Block a user