C++实现奶茶订单求解

我用C++实现一个奶茶订单的,可是最后却怎么也成功不了,我是一个初学者萌新,请问有没有大佬帮我看看,应该怎么改呀,真的哭泣

#include
#include
using namespace std;

class Naicha{

string description;

public:
string setDescription(string description){

this->description = description;

}

string getDescription(){
	return description;
}

public:
virtual double cost();
};

class CondimentDecorator:public Naicha{

public:
string getDescription();
};

class wulong:public Naicha{

public:
wulong(){
Naicha beverage;
beverage.setDescription(“wulong”);
}
public:
double cost(){
return 1.99;
}
};

class hongcha:public Naicha{

public:
hongcha(){
Naicha naicha;
naicha.setDescription(“hongcha”);
}
public:
double cost(){
return 0.99;
}
};

class tieguanyin:public Naicha{

public:
tieguanyin(){
Naicha naicha;
naicha.setDescription(“tieguanyin”);
}
public:
double cost(){
return 1.05;
}
};

class lvcha:public Naicha{

public:
lvcha(){
Naicha naicha;
naicha.setDescription(“lvcha”);
}
public:
double cost(){
return 1.99;
}
};

class zhenzhu:public CondimentDecorator{
Naicha naicha;

public:
zhenzhu(Naicha beverage){
this->naicha = naicha;
}

public:
string getDescription(){
return naicha.getDescription() + “,zhenzhu”;
}

public:
double cost(){
return 0.20+naicha.cost();
}
};

class yeguo:public CondimentDecorator{
Naicha naicha;

public:
yeguo(Naicha beverage){
this->naicha = naicha;
}

public:
string getDescription(){
return naicha.getDescription() + “,yeguo”;
}

public:
double cost(){
return 0.10+naicha.cost();
}
};

class yuyuan:public CondimentDecorator{
Naicha naicha;

public:
yuyuan(Naicha beverage){
this->naicha = naicha;
}

public:
string getDescription(){
return naicha.getDescription() + “,yuyuan”;
}

public:
double cost(){
return 0.10+naicha.cost();
}
};

class naigai:public CondimentDecorator{
Naicha naicha;

public:
naigai(Naicha naicha){
this->naicha = naicha;
}

public:
string getDescription(){
return naicha.getDescription() + “,naigai”;
}

public:
double cost(){
return 0.15+naicha.cost();
}
};

int main()
{
Naicha naicha = new wulong();
cout<

Naicha naicha2 = new tieguanyin();
naicha2 = new yuyuan(naicha2);
naicha2 = new zhenzhu(naicha2);
naicha2 = new yuyuan(naicha2);
cout<

}

你可能感兴趣的:(c++)