int main() { Cabinet *Cab; Cab = Cabinet::Instance(); //instance of cabinet IngredientDatabase *IngDB; IngDB = IngredientDatabase::Instance(); //instance of ingredient database CocktailDB *CDB; CDB = CocktailDB::Instance(); //instance of cocktail database IngDB->PopulateDB("ingredientDatabase.txt"); CDB->ProcessFile("cocktailDatabase.txt"); int command; string input; cout << "CS 441 Mixology Project - Unit Test 2" << endl; while(1) { cout << "<<Cabinet>>" << endl; Cab->DisplayCab(); cout << endl; cout << "1 - Add Ingredient to Cabinet" << endl; cout << "2 - Remove Ingredient from Cabinet" << endl; cout << "3 - View Possible Ingredients" << endl; cout << "4 - Clear Cabinet" << endl; cout << "5 - Display Cocktail Database" << endl; cout << "6 - Find Cocktail" << endl; cout << "7 - I'm Feeling Lucky" << endl; cout << "0 - Exit" << endl; cin >> command; if(command == 1) { cout << "Enter Ingredient to Add" << endl; cin.ignore(); getline(cin, input); Ingredient newIng(input); newIng.FormatIng(); Cab->AddIng(newIng, *IngDB); } else if(command == 2) { cout << "Enter Ingredient to Remove" << endl; cin.ignore(); getline(cin, input); Ingredient ingToDelete(input); ingToDelete.FormatIng(); Cab->RemoveIng(ingToDelete); } else if(command == 3) { cout << "<<Possible Ingredients>>" << endl; IngDB->displayDB(); cout << endl; } else if(command == 4) { Cab->clearIngs(); cout << "Cabinet Cleared" << endl; } else if(command == 5) { CDB->display(); } else if(command == 6) { cout << "Enter Cocktail to Find" << endl; cin.ignore(); getline(cin, input); Cocktail newCocktail = CDB->findCocktail(input); if(newCocktail.getCocktailName() == "nothing") cout << "Could not find cocktail" << endl; else newCocktail.printCocktailRecipe(); } else if(command == 7) CDB->imFeelingLucky(); else if(command == 0) break; else if(cin.fail()) { cout << "Not a valid input" << endl; cin.clear(); cin.ignore(256, '\n'); } else cout << "Not a valid input" << endl; } cout << "Program Terminated" << endl; return 0; }
int main() { Cabinet* cabinet = new Cabinet("PC cabinet"); Chassis* chassis = new Chassis("PC Chassis"); cabinet->Add(chassis); chassis->Add(new FloppyDisk("3.5 in Floppy")); return 0; }
void dummy1 () { Cabinet* cabinet = new Cabinet("PC Cabinet"); Chassis* chassis = new Chassis("PC Chassis"); cabinet->Add(chassis); Bus* bus = new Bus("MCA Bus"); bus->Add(new Card("16Mbs Token Ring")); chassis->Add(bus); chassis->Add(new FloppyDisk("3.5in Floppy")); std::cout << "The net price is " << chassis->NetPrice() << std::endl; }
int main() { Cabinet<std::string> cabinet; auto ptr = cabinet.insert("Foobar"); assert(*ptr == "Foobar"); auto foo = cabinet.insert("Foo"); auto bar = cabinet.insert("Bar"); auto baz = cabinet.insert("Baz"); cabinet.remove(ptr); assert(*foo == "Foo"); assert(*bar == "Bar"); assert(*baz == "Baz"); bar.remove(); assert(*foo == "Foo"); assert(*baz == "Baz"); baz.remove(); assert(*foo == "Foo"); foo.remove(); assert(cabinet.size() == 0); return 0; }
vector<Cocktail> CocktailDB::SearchByIngredient(Cabinet cab) { vector<Ingredient> cabIngList; cabIngList = cab.GetCabIngList(); vector<Cocktail> tempCTDB = dataBase; for (int x = 0; x < (tempCTDB.size() - 1); x++) { int total = tempCTDB[x].GetNumOfIngredients(); for (int i = 0; i < (cabIngList.size() - 1); i++) { total -= tempCTDB[x].VisitIngredient(cabIngList[i]); } tempCTDB[x].SetIngNeeded(total); } return SortByIngNeeded(tempCTDB); }