int main() { char choice; char name[80]; int number; int found; SymbolTable book; int i; /* initialize phone book */ book = createSymbolTable(&makePhoneBook, &comparePhone); do{ choice = getMenu(); switch(choice){ case '1': printf("Enter the name: "); scanf("%[^\n]", name); myfflush(); printf("Enter the number: "); scanf("%d", &number); myfflush(); addEntry(&number, &name, &book); printf("%d\n", book.total); break; case '2': printf("Enter the number you want to find: "); scanf("%d", &number); myfflush(); found = getEntryValue(&number, &book); if(found == -1) printf("Not found\n"); else{ displayTitle(); displayEntry(book.entries[found]); } break; case '3': displayTitle(); for(i = 0; i < book.current; i++){ displayEntry(book.entries[i]); } break; case '4': dropSymbolTable(&book); break; default: printf("Invalid choice\n"); } }while(choice != EXIT); }
void TerminalAbstractState::displayCard(CardId id, bool displayValue, int value) { auto cardData = _context.client->getCardData(id); assert(cardData->isCreature() or cardData->isSpell()); if(cardData->isCreature()) { const ClientCreatureData* castedCardData{dynamic_cast<const ClientCreatureData*>(cardData)}; assert(castedCardData != nullptr); if (displayValue) displayNumberedEntry(std::string(castedCardData->getName()) + " (creature)", value); else displayEntry(std::string(castedCardData->getName()) + " (creature)"); displayEntry(std::string("cost: ") + std::to_string(castedCardData->getCost()) + ", attack: " + std::to_string(castedCardData->getAttack()) + ", health: " + std::to_string(castedCardData->getHealth()) + ", shield: " + std::to_string(castedCardData->getShield()) + "-" + std::to_string(castedCardData->getShieldType()), '-', 1); displayEntry(castedCardData->getDescription(), '-', 1); } else { const ClientSpellData* castedCardData{dynamic_cast<const ClientSpellData*>(cardData)}; assert(castedCardData != nullptr); if (displayValue) displayNumberedEntry(std::string(castedCardData->getName()) + " (spell)", value); else displayEntry(std::string(castedCardData->getName()) + " (spell)"); displayEntry(std::string("cost: ") + std::to_string(castedCardData->getCost()), '-', 1); displayEntry(castedCardData->getDescription(), '-', 1); } }
void ICACHE_FLASH_ATTR displayCb(void) { clearLcd(); if (strlen(valueEntries[startTemp].type) > 0) { displayEntry(startTemp); } }