double cost() {
     cout << "size: " << this->getSize() << endl;
     if (this->getSize() == 16)
         return beverage->cost() + 0.4;
     else if (this->getSize() == 20)
         return beverage->cost() + 0.6;
     else // 24
         return beverage->cost() + 0.8;
 }
示例#2
0
int main(int argc, char *argv[])
{
	Beverage *beverage = new Espresso();
	cout << beverage->get_desc() << ": $" << beverage->cost() << endl;

	beverage = new Mocha(beverage);
	cout << beverage->get_desc() << ": $" << beverage->cost() << endl;

	Beverage *beverage2 = new HouseBlend();
	beverage2 = new Mocha(beverage2);
	beverage2 = new Mocha(beverage2);
	cout << beverage2->get_desc() << ": $" << beverage2->cost() << endl;

	return 0;
}
void StarbuzzCoffee() {
    Beverage * beverage = new Espresso();
    std::cout << beverage->getDescription() << " $" << beverage->cost() << std::endl;
    std::cout << "-------------------------" << std::endl;

    Beverage * beverage2 = new DarkRoast();
    std::cout << beverage2->getDescription() << " $" << beverage2->cost() << std::endl;
    beverage2 = new Mocha(beverage2);
    beverage2 = new Whip(beverage2);
    std::cout << beverage2->getDescription() << " $" << beverage2->cost() << std::endl;
    std::cout << "-------------------------" << std::endl;

    Beverage * beverage3 = new HouseBlend();
    std::cout << beverage3->getDescription() << " $" << beverage3->cost() << std::endl;
    beverage3 = new Soy(beverage3);
    beverage3 = new Mocha(beverage3);
    beverage3 = new Whip(beverage3);
    std::cout << beverage3->getDescription() << " $" << beverage3->cost() << std::endl;
    std::cout << "-------------------------" << std::endl;


    Beverage * beverage4 = new Decaf();
    std::cout << beverage4->getDescription() << " $" << beverage4->cost() << std::endl;
    beverage4 = new Milk(beverage4);
    std::cout << beverage4->getDescription() << " $" << beverage4->cost() << std::endl;
    std::cout << "-------------------------" << std::endl;

}
示例#4
0
int main(int argc,char* argv[])
{

	int a = 0;
	int b = a++;
	int c = ++a;
	int intArray[10] = {0};
	short* p = (short*)intArray;
	for (int i = 0; i <10; ++i)
	{
		*p = i;
		p+= 2;
	}

	Beverage* Es = new Espresso();
	printf("%s+$ %f\n",Es->GetDescription().c_str(),Es->cost());

	Beverage* beverage2 = new DarkRoast();
	beverage2 = new Mocha(beverage2);
	beverage2 = new Mocha(beverage2);
	beverage2 = new Whip(beverage2);
	printf("%s+$ %f\n",beverage2->GetDescription().c_str() ,beverage2->cost());

	Beverage* beverage3 = new HouseBlend();
	beverage3 = new Soy(beverage3);
	beverage3 = new Mocha(beverage3);
	beverage3 = new Whip(beverage3);
	printf("%s+$ %f\n",beverage3->GetDescription().c_str() , beverage3->cost());
	
	return 0;
}
示例#5
0
int main() {
  Beverage* beverage = new Espresso();
  cout << beverage->getDescription() << "$ " << beverage->cost() << endl;
  delete beverage;

  Beverage* beverage2 = new DarkRoast();
  beverage2 = new Mocha(beverage2);
  beverage2 = new Mocha(beverage2);
  beverage2 = new Whip(beverage2);
  cout << beverage2->getDescription() << "$ " << beverage2->cost() << endl;
  delete beverage2;

  Beverage* beverage3 = new DarkRoast();
  beverage3 = new Soy(beverage3);
  beverage3 = new Mocha(beverage3);
  beverage3 = new Whip(beverage3);
  cout << beverage3->getDescription() << "$ " << beverage3->cost() << endl;
  delete beverage3;

  return 0;
}
int Starbuzz_Coffee::main(int argc, char *argv[])
{
	using namespace std;

	Beverage *beverage = new Espresso();
	cout << beverage->get_description() << " $" << beverage->cost() << endl;
	delete beverage;

	Beverage *beverage2 = new Dark_Roast();
	beverage2 = new Mocha(beverage2);
	beverage2 = new Mocha(beverage2);
	beverage2 = new Whip(beverage2);
	cout << beverage2->get_description() << " $" << beverage2->cost() << endl;
	delete beverage2;

	Beverage *beverage3 = new House_Blend();
	beverage3 = new Soy(beverage3);
	beverage3 = new Mocha(beverage3);
	beverage3 = new Whip(beverage3);
	cout << beverage3->get_description() << " $" << beverage3->cost() << endl;
	delete beverage3;

	return 0;
}
	public: double cost() const {
		return 0.10 + _beverage->cost();
	}
示例#8
0
void print_beverage(const Beverage& bev)
{
    cout << bev.get_description() << ": " << bev.cost() << endl;
}
 double cost() {return beverage->cost() + 0.2;}
	double cost() {
		return myPrice + myBeverage->cost();
	}
示例#11
0
 virtual double cost()
 {
     return beverage->cost() + costs*beverage->getSize();
 }