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

    InstrumentFactory * trumpetFactory = FactoryCreator::createTrumpetFactory();
    InstrumentFactory * drumFactory = FactoryCreator::createDrumFactory();
    InstrumentFactory * guitarFactory = FactoryCreator::createGuitarFactory();

    Instrument * trumpet = trumpetFactory->createInstrument();
    Instrument * drum = drumFactory->createInstrument();
    Instrument * guitar = guitarFactory->createInstrument();

    trumpet->play();
    drum->play();
    guitar->play();
}
示例#2
0
void tune (Instrument &i){
	i.prepare();
	i.play(middleC);

}
示例#3
0
void tune(Instrument& i) {
  // ...
  i.play(middleC);
}
示例#4
0
void play(Instrument& i) {
  cout << "Playing a " << i.what() << "... ";
  i.play(middleC);
}
//DO NOT MODIFY this function
void tune(Instrument& i)
{
      i.play("middleC");
}