Cookie::Cookie(const std::string& name, const std::string& value, const std::vector<std::string>& options) : Cookie{name, value} { // Check that the vector has an even number of elements (key, value) if(options.size() % 2 not_eq 0) throw CookieException{"Invalid number of elements in cookie's options vector!"}; // for-loop on vector - set input values from vector: for(size_t i = 0; i < options.size(); i += 2) { std::string nm = options[i]; if(not valid_option_name(nm)) throw CookieException{"Invalid name (" + nm + ") of cookie option!"}; std::string val = options[i+1]; if(caseInsCompare(nm, C_EXPIRES)) { set_expires(val); } else if(caseInsCompare(nm, C_MAX_AGE)) { try { int age = std::stoi(val); if(age < 0) throw CookieException{"Invalid max-age attribute (" + val + ") of cookie! Negative number of seconds not allowed."}; set_max_age(age); } catch(std::exception& e){ throw CookieException{"Invalid max-age attribute (" + val + ") of cookie! Invalid integer value."}; } } else if(caseInsCompare(nm, C_DOMAIN)) { set_domain(val); } else if(caseInsCompare(nm, C_PATH)) { set_path(val); } else if(caseInsCompare(nm, C_SECURE)) { bool s = (caseInsCompare(val, "true")) ? true : false; set_secure(s); } else if(caseInsCompare(nm, C_HTTP_ONLY)) { bool s = (caseInsCompare(val, "true")) ? true : false; set_http_only(s); } } }
Deer::Deer() { /* set_move_made(false); set_max_age(30); set_curr_age(0); set_max_calories(55); set_curr_calories(0); set_metabolic_rate(4); set_calories_per_grass(5); set_calories_per_20_grass(2); set_calories_per_flower(6); set_calories_per_30_flowers(3); set_reproductive_rate(40); set_min_age_to_reproduce(12); set_min_calories_to_reproduce(40); set_min_calories_to_evade(35); */ set_move_made(false); set_max_age(30); set_curr_age(0); set_max_calories(45); set_curr_calories(10); set_metabolic_rate(4); set_calories_per_grass(7); set_calories_per_20_grass(2); set_calories_per_flower(7); set_calories_per_30_flowers(3); set_reproductive_rate(40); set_min_age_to_reproduce(12); set_min_calories_to_reproduce(40); set_min_calories_to_evade(35); image.create(TILE_SIZE,TILE_SIZE, sf::Color::Blue); if(!image.loadFromFile("img/deer.png")){ cout << "Could not load image" << endl; } this->texture.update(image); }