Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<windows.h>
- #include<iostream>
- #include<stdio.h>
- #include<stdlib.h>
- #include <unistd.h>
- #include <cstdlib>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int money=0;
- bool charger_status=false;
- bool charger_status2=true;
- int password=0;
- bool time_check=true;
- int time_mm;
- int t=1;
- int check_password_fail;
- bool password_check(int pass )
- {
- if(pass==password)
- {
- cout<<"correct password !!!!"<<endl;
- Sleep(2000);
- return true;
- }
- else
- { check_password_fail+=1;
- cout<<"incorrect password"<<endl;
- Sleep(2000);
- return false;
- }
- }
- void timer(int minute)
- {
- int h=0,m=0,s=0;
- s++;
- while(true)
- {
- system("CLS") ;
- if(s==minute)
- {
- return;
- }
- if(s==60)
- {
- s=0;
- m++;
- if(m==60)
- {
- m=0;
- h++;
- if(h==24)
- {
- h=0;
- }
- }
- }
- printf("Charge time %d:%d:%d \n",h,m,s);
- Sleep(1000);
- s++;
- }
- }
- int generate_password()
- {
- srand(time(NULL));
- return rand() % (10000 - 90000) + 10000 ;
- }
- void charge(int m)
- {
- cout<<"plese connect cable to your device if finished please input 1"<<endl;
- int choice;
- cin>>choice;
- while(!(choice==1))
- {
- cin>>choice;
- }
- password=generate_password();
- cout<<"your password : "<<password<<endl;
- Sleep(3000);
- timer(m);
- charger_status=true;
- return;
- }
- int money_check(int choice,int m)
- {
- int temp_money=choice*30;
- if(m==temp_money)
- {
- t=0;
- charge(m);
- return 0;
- }
- if(m>temp_money)
- {
- int result = m-temp_money;
- t=0;
- cout<<"return = "<<result<<" baht."<<endl;
- charge(temp_money);
- return 0;
- }
- else
- {
- cout<<"not enough money return "<<m<<" baht."<<endl;
- Sleep(3000);
- timer(30);
- return 99;
- }
- }
- void service ()
- {
- while(t)
- {
- int choice;
- system("CLS") ;
- cout<<"1) 30 minute 30 baht."<<endl;
- cout<<"2) 60 minute 60 baht."<<endl;
- cout<<"3) 90 minute 90 baht."<<endl;
- cout<<"please input choice <<";
- cin>>choice;
- switch (choice)
- {
- case 1:
- cout<<"please insert money << ";
- cin>>money;
- if( money_check(choice,money)==99 ){return; }
- break;
- case 2:
- cout<<"please insert money << ";
- cin>>money;
- money_check(choice,money);
- if( money_check(choice,money)==99 ){return; }
- break;
- case 3:
- cout<<"please insert money << ";
- cin>>money;
- money_check(choice,money);
- if( money_check(choice,money)==99 ){return; }
- break;
- default:
- cout<<"please try again."<<endl;
- return;
- break;
- }
- }
- }
- int main()
- {
- cout<<"Wellcome "<<endl;
- check_password_fail=0;
- int choice =0;
- while(true)
- {
- choice=0;
- if(check_password_fail==3)
- {
- system("CLS") ;
- cout<<"\n Please contrack call center to unlock your phone. "<<endl;
- Sleep(3000);
- return 0;
- }
- system("CLS") ;
- cout<<"------------menu---------------"<<endl;
- cout<<"1) charge your mobile phone "<<endl;
- cout<<"2) get your mobile phone back "<<endl;
- cout<<"input choice<< ";
- cin>>choice;
- if(choice==1)
- {
- if(!charger_status)
- {
- t=1;
- service();
- }
- else
- {
- cout<<"please get your mobile phone"<<endl;
- Sleep(500);
- }
- }
- else if(choice==2)
- {
- if(charger_status)
- {
- cout<<"Enter your password << " ;
- int p;
- cin>>p;
- if(password_check(p))
- {
- system("CLS") ;
- generate_password();
- cout<<"finished"<<endl;
- Sleep(2000);
- system("CLS") ;
- check_password_fail=0;
- cout<<"---------------Thank You----------------"<<endl;
- Sleep(2000);
- charger_status=false;
- }
- }
- else
- {
- t=1;
- service();
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement