OOP244 Project - Milestone5


This article shows some code examples with an idea of each milestone. All examples are just my own idea, it means it is not the only solution and can be wrong. There are a lot of better approaches for solving the problems. Just refer it as one way of ideas. If you have a different one, keep going with that!

Milestone5

1. Standard Input

Capture whole sentence with white space.

    char c[2048];
    double d = 0;
    bool b = true;
    int i = 0;

    std::cout << "Item Entry:" << std::endl;
    std::cout << "Sku: ";
    is >> c;
    sku(c);

    //#bug compound words not support
    std::cout << "Name:\n";
    is.ignore();
    is.getline(c, 81, '\n');
    name(c);
    if (is.gcount() >= 80) {    //when the name over 80
        is.clear();
        is.ignore(2000, '\n');
    }

    std::cout << "Price: ";
    is >> d;
    if (is.fail()) {
        error("Invalid Price Entry");
        //is.setstate(std::ios::failbit);
        return is;
    }
    price(d);