-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (41 loc) · 1.38 KB
/
main.cpp
File metadata and controls
53 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
auto my_searching_function(std::string what_to_find, std::string find_whitin,double price) {
int drink_existed = 0;
auto pricegiver = [price](std::string drink){
std::cout<<"This drink will cost "<<price <<"Ft"<<std::endl;
};
auto searching=[pricegiver,what_to_find,find_whitin,price,&drink_existed](){
size_t my_bool = find_whitin.find(what_to_find);
if(my_bool != std::string::npos){
pricegiver(what_to_find);
drink_existed++;
}
};
searching();
return drink_existed;
}
int searchin(std::string drink){
int i =0;
i+=my_searching_function("Cola",drink,340);
i+=my_searching_function("Tonic",drink,320);
i+=my_searching_function("Sprite",drink,330);
i+=my_searching_function("Natur Aqua",drink,250);
return i;
}
int main(int, char**) {
std::cout<< "What kind of drink would you like?" <<std::endl;
std::string string_object;
while(1){
std::cin>> string_object;
int i =searchin(string_object);
if(i<1){std::cout<<"Please select a real drink"<<std::endl;}
std::cout<<"Please type exit if you are finished"<<std::endl;
size_t my_bool = string_object.find("exit");
if(my_bool != std::string::npos){exit(0);}
}
}