#ifndef INVOICE_H
#define INVOICE_H
#include <iostream>
#include <string>
using namespace std;
class Invoice
{
public:
Invoice(string,string,int,int);
~Invoice();
void setNum(int);
void setPrice(int);
int getInvoiceAmount();
void displayMessage();
private:
string m_id;
string m_name;
int m_num;
int m_price;
};
#endif
#include "Invoice.h"
Invoice::Invoice(string id,string name,int num,int price)
:m_id(id),
m_name(name),
m_num(num),
m_price(price)
{
setNum(num);
setPrice(price);
}
Invoice::~Invoice()
{
}
void Invoice::setNum(int num)
{
m_num = 0;
if (num > 0)
m_num = num;
}
void Invoice::setPrice(int price)
{
m_price = 0;
if (price > 0)
m_price = price;
}
int Invoice::getInvoiceAmount()
{
return (m_num*m_price);
}
void Invoice::displayMessage()
{
cout << "产品编号:" << m_id << ' '
<< "产品描述:"