void main(int,char**){ Phone *phone = new Phone(); phone->CreateVirtual("/Devices/Input/Dialogic"); Meteorites *game = new Meteorites(); game->MessageLoop(); printf("Deleting game\n"); delete game; printf("Leaving\n"); }
int main() { Phone* nokia = SimpleFactory::createPhone("Nokia"); nokia->doCall("13988888888"); Phone* apple = SimpleFactory::createPhone("Apple"); apple->doCall("158999999999"); delete nokia; delete apple; return 0; }
int main(int argc, char *argv[]) { NokiaFactory nokia; Phone* pm = nokia.CreateNokiaPhone("music"); pm->print_type(); Phone* pc = nokia.CreateNokiaPhone("commercial"); pc->print_type(); return 0; }
ArrayElement* Phone::clone() { Phone* ret = new Phone(); if (p) { ret->setProperty(*p); } if (t) { ret->setType(t); } return (ArrayElement *)ret; }
void PhoneModel::editPhone(int contractorId, Phone newPhone) { query = new QSqlQuery(Database::getInstance().db); query->prepare("UPDATE contractors_phones SET phone_name = ?, number = ?, is_default = ? " "WHERE contractors_phones.id_contractors_phone = ? and contractor = ?"); query->addBindValue(newPhone.getName()); query->addBindValue(newPhone.getNumber()); query->addBindValue(QVariant(newPhone.isDefault()).toInt()); query->addBindValue(newPhone.getId()); query->addBindValue(contractorId); query->exec(); if(this->isQueryError(query)) throw new SQLException("PhoneModel::editPhone", query); delete query; }
int main(int argc, char *argv[]) { QString path(":/style"); QFile stylefile(path); QApplication a(argc, argv); stylefile.open(QFile::ReadOnly); a.setStyleSheet(stylefile.readAll()); a.setFont(QFont("simfang",11)); QTextCodec *code=QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(code); //QTextCodec::setCodecForCStrings(code); //QTextCodec::setCodecForTr(code); Phone w; w.setWindowFlags(Qt::FramelessWindowHint); //w.setGeometry(0, 0, 800, 480); w.resize(800,480); w.show(); return a.exec(); }
void PhoneModel::addPhone(int contractorId, Phone phone) { if(phone.getName().isEmpty()) phone.setName("."); if(phone.getNumber().isEmpty()) phone.setNumber("."); query = new QSqlQuery(Database::getInstance().db); query->prepare("INSERT INTO contractors_phones (contractor, phone_name, number, is_default) " "VALUES (?, ?, ?, ?)"); query->addBindValue(contractorId); query->addBindValue(phone.getName()); query->addBindValue(phone.getNumber()); query->addBindValue(QVariant(phone.isDefault()).toInt()); query->exec(); if(this->isQueryError(query)) throw new SQLException("PhoneModel::addPhone", query); delete query; }
void promptForAddress(AddressBook &book) { while(true) { cout << "Enter person ID number [0 to quit]: "; Person person; { int id; cin >> id; if (!id) break; person.setId(id); cin.ignore(256, '\n'); } { cout << "Enter name: "; std::string name; getline(cin, name); person.setName(name); } { cout << "Enter email address (blank for none): "; string email; getline(cin, email); if (!email.empty()) person.setEmail(email); } while(true) { cout << "Enter a phone number [Enter to finish]: "; string number; getline(cin, number); if (number.empty()) break; Phone *phone = person.add_phone(); phone->setNumber(number); cout << "Is this a mobile, home or work phone? "; string type; getline(cin, type); if ("mobile" == type) phone->setType(Phone::MOBILE); else if ("home" == type) phone->setType(Phone::HOME); else if ("work" == type) phone->setType(Phone::WORK); else cout << "Unknown phone type. Using default." << endl; } book.push_back(person); } }