-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtejia.cpp
More file actions
34 lines (27 loc) · 765 Bytes
/
tejia.cpp
File metadata and controls
34 lines (27 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include "tejia.h"
using namespace std;
#include <sstream>
int Tejia::getType()const{
return 3; //3 表示特价商品
}
string Tejia::getInfo()const{
ostringstream ostr;
ostr<<getType()<<" "; //先输出类型编码
ostr<<Commodity::getInfo(); //输出基类的信息
return ostr.str();
}
Tejia::Tejia(long id,std::string name,
double p,int n)
:Commodity(id,name,p,n){}
Tejia::Tejia(std::string name,double p,
int n)
:Commodity(name,p,n){}
double Tejia::getNetPrice()const{
return Commodity::getNetPrice();
}
void Tejia::output()const{
Commodity::output();
cout<<" 商品总价:"<<getNetPrice()<<" (特价价格:"
<<getPrice()<<", 数量:"<<getNum()<<")\n";
}