Beispiel #1
0
int main(void)
{
  book_t b;
  book_set(&b, "Pendulum", "Umberto Eco", "*****@*****.**");

  book_print(&b);

  return 0;
}
Beispiel #2
0
void book_view()
{
	system("cls");

	char ch;

	cout << "How would you like to view the books?" << endl << endl;
	cout << "1. All books" << endl;
	cout << "2. Available books" << endl;
	cout << "3. Lent books" << endl;
	cout << "4. Overdue books" << endl;
	cout << "5. I don't, go back" << endl;
	stahp();

	cin >> ch;

	switch (ch)
	{
	case '1':
		book_print();
		break;
	case '2':
		c_book_print(true);
		break;
	case'3':
		c_book_print(false);
		break;
	case '4':
		overdues(1);
		break;
	case'5':
		break;
	default:
		cout << "Please provide a valid response." << endl;
		cin.clear();
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		book_view();
		break;
	}
}
Beispiel #3
0
int
shelf_test (bool verbose)
{
    printf (" * shelf: ");
    zconfig_t* config = zconfig_load(".testdir/test.cfg");
    assert(config); 
    zpgutil_datasource_t *datasource = zpgutil_datasource_new (config);
    assert (datasource);
    zpgutil_session_t *session = zpgutil_session_new (datasource);
    assert (session);
 
    //  @selftest
    //  Simple create/destroy test
    shelf_t *self = shelf_new (session);
    assert (self);
    book_t *mybook = shelf_add_book (self,"William Shakespeare","Macbeth");
    assert (mybook);
    book_destroy (&mybook);

    int c = shelf_count_books (self);
    assert (c>0);

    shelf_load_books (self);
    book_t *loaded;
    while ( (loaded = shelf_next_book (self)) != NULL)
    {
      book_print (loaded);
      book_destroy (&loaded);
    }
    shelf_destroy (&self);
    //  @end

    zpgutil_session_destroy (&session);
    zpgutil_datasource_destroy (&datasource);
    zconfig_destroy (&config);

    printf ("OK\n");
    return 0;
}