MarauderXtreme / bookshop-schiller

This is a spring project for university. It is a small sales point application for a bookshop.
Other
0 stars 1 forks source link

Check for id doubles #36

Open MarauderXtreme opened 9 years ago

MarauderXtreme commented 9 years ago

We should implement a check for double ids like ISBN or EAN. I don't know if the checks happens through Spring-Annotation.

marcel-liebgott commented 9 years ago

Did you have a ISBN validation too? Here an example in c++ from my proof

bool BOOK::isIsbnValid(){
    if(this->_isbn.GetCstring() != NULL){
        int x = 0, g = 0, u = 0, s1 = 0, s2 = 0;

        // bereinige den String von '-'
        this->_isbn.CstringReplace('-');

        // rechne alle geraden Felder zusammen
        for(g = 0; g < 13; g += 2){
            s1 += this->_isbn[g];
        }

        // rechne alle ungerade Felder zusammen
        for(u = 1; u < 13; u += 2){
            s2 += this->_isbn[u];
        }

        x = (10 - ((s1 + 3*(s2))) % 10);

        if((x % 10) == 0){
            return true;
        }else{
            cout << (x % 10) << endl;
            throw invalid_argument(string("invalide ISBN"));
        }
    }else{
        throw invalid_argument(string("Argumentfehler, ISBN Validierung, BOOK, ISBN"));
    }
    return false;
}
MarauderXtreme commented 9 years ago

No we hadn't this. I will have a look at this and try to implement it. Thank you.

marcel-liebgott commented 9 years ago

I will add these feature and will provide a pull request ;) coming soon

MarauderXtreme commented 9 years ago

Pull request has been merged. d960aa2d26217c6e5b936e741a5f5c2c6bb7f158 Thanks for validation. Still we need to check if there are copies.

marcel-liebgott commented 9 years ago

Of cource. I will spend some time to get a solution.