void playWithHomeTheater() { // Create all the parts of the home theatre system Amplifier amp("Top-O-Line Amplifier"); CdPlayer cd("Top-O-Line CD Player", &); DvdPlayer dvd("Top-O-Line DVD Player", &); Screen screen("My Theater Screen"); PopcornPopper popper("My Popcorn Popper"); Tuner tuner("Top-O-Line AM/FM Tuner", &); TheaterLights lights("Theater Ceiling Lights"); Projector projector("Top-O-Line Projector"); popper.on(); // Turn on the popcorn popper... popper.pop(); // and start popping... lights.dim(10); // Dim the lights to 10%... screen.down(); // Put the screen down... projector.on(); // Turn on the projector... projector.setInput(&dvd); // set it to DVD... projector.wideScreenMode(); // and put it on wide screen mode for the movie... amp.on(); // Turn on the amp... amp.setInput(&dvd); // set it to DVD and... amp.setSurroundSound(); // put it into surround sound mode... amp.setVolume(11); // and set the volume to 11... dvd.on(); // Turn on the DVD player... dvd.play("Raiders of the lost ark"); // and FINALLY, play the movie! // What about shutting everything down again?! // How would you play a CD? etc... }
int judge() { int i; for(i=n;i>=1;i--) if(n%i==0 && dvd(i)) return i; }
void mptan(double x, mp_no *mpy, int p) { static const double MONE = -1.0; int n; mp_no mpw, mpc, mps; n = mpranred(x, &mpw, p) & 0x00000001; /* negative or positive result */ c32(&mpw, &mpc, &mps, p); /* computing sin(x) and cos(x) */ if (n) /* second or fourth quarter of unit circle */ { dvd(&mpc,&mps,mpy,p); mpy->d[0] *= MONE; } /* tan is negative in this area */ else dvd(&mps,&mpc,mpy,p); return; }
int main(int argc, const char **argv){ char buffer[MAX]; struct Stack operando; do { system("clear"); for (int i=0; i<operando.cima; i++) printf("%.2lf\n", operando.data[i]); printf("Comando: "); scanf(" %s", buffer); if (isdigit(buffer[0])) push(atof(buffer), &operando); else switch(find(buffer)){ case 0: push( sum(pop(&operando), pop(&operando)), &operando ); break; case 1: push( res(pop(&operando), pop(&operando)), &operando ); break; case 2: push( mul(pop(&operando), pop(&operando)), &operando ); break; case 3: push( dvd(pop(&operando), pop(&operando)), &operando ); break; } } while (strcasecmp(buffer, "quit")); return EXIT_SUCCESS; }
void playWithHomeTheaterFacade() { // Create all the parts of the home theatre system // Not encapsulated or owned by the facade. Amplifier amp("Top-O-Line Amplifier"); CdPlayer cd("Top-O-Line CD Player", &); DvdPlayer dvd("Top-O-Line DVD Player", &); Screen screen("My Theater Screen"); PopcornPopper popper("My Popcorn Popper"); Tuner tuner("Top-O-Line AM/FM Tuner", &); TheaterLights lights("Theater Ceiling Lights"); Projector projector("Top-O-Line Projector"); HomeTheaterFacade theater(&, &tuner, &dvd, &cd, &projector, &lights, &screen, &popper); theater.watchMovie("Raiders of the Lost Ark"); theater.endMovie(); }
/* This function determines the type of operation and calls a function to perform it Pre: option contains the operation num1 & num2 contains data Post: returns the result */ float calc ( int option, float num1, float num2 ) { /* Prototype Statements */ float add ( float num1, float num2 ) ; float sub ( float num1, float num2 ) ; float mul ( float num1, float num2 ) ; float dvd ( float num1, float num2 ) ; /* Local Declarations */ float result ; /* Statements */ switch ( option ) { case 1 : result = add ( num1, num2 ) ; break; case 2 : result = sub ( num1, num2 ) ; break; case 3 : result = mul ( num1, num2 ) ; break; case 4 : if ( num2 == 0.0 ) { printf ( "\n\a\aError: " ) ; printf ( "division by zero ***\n" ) ; exit ( 1 ) ; } else result = dvd ( num1, num2 ) ; break ; /* Better structured programming would validate the option in getOption. However we have not yet learned the technique to put it there. */ default : printf ( "\aOption not available\n" ) ; exit ( 1 ) ; } /* switch */ return result ; } /* calc */
bool k9batch::exec(int argc, char** argv) { bool isBatch=false; for (int i=0; i < argc; i++) if (strcmp(argv[i],"--batch")==0) isBatch=true; if (!isBatch) return false; QApplication app(argc,argv,false); for (int i=0 ;i < app.arguments().count();i++) { QString arg=app.arguments().at(i); QString nextArg=""; if (i< app.arguments().count() -1) nextArg=app.arguments().at(i+1); if (arg.startsWith("--")) args[arg.replace("--","")]= nextArg.startsWith("--") ? "" : nextArg; } if (args.contains("help")){ showHelp(); return true; } k9Tools::setBatchCopy(true); k9DVD dvd(NULL); dvd.scandvd(args["input"],true); k9ExecCopy execCopy; execCopy.setDvd ( &dvd ); QString path; execCopy.setCopyMenus ( args.contains("backup-menus")); if (args.contains("output-size")) { bool ok; int size; size=args["output-size"].toInt(&ok); if (ok) execCopy.setDvdSize(qMin(size,8500)); } doSelect(dvd); //execCopy.setSpeed ( Ui_MainDlg.cbBurnSpeed->currentText() ); bool bFolder,bISO; bISO=args["output"].endsWith(".iso"); bFolder =!bISO; if ( bFolder) { execCopy.setOutput ( k9ExecCopy::oFolder ); // changed from home to preferred output directory (bkp) path= args["output"]; if ( path=="" ) return true; } else if ( bISO) { // changed QDir::homePath() to m_prefOutput (bkp) path= args["output"]; if ( path =="" ) return true; execCopy.setOutput ( k9ExecCopy::oISO ); } execCopy.setPath ( path ); execCopy.copyDVD(); return true; }