/*Quiz game project using c++
****************************/
#include<iostream>
using namespace std;
class Quiz_game // this is the main class /*concept of classes*/
{
private: /*private part of the class*/
string address; //declear the data member in the private part
protected:
string name;
public: /*public part of the class*/
/*declear member functions of the class*/
inline void player_info(); //this function is for get the some player information
inline void menu(); //this function is for the menu
};
inline void Quiz_game::menu() /*concept of declearing member functions outside the class*/
{
cout<<"\n\n\n";
cout<<"\t\t\t\t\t\tWELCOME\n"<<endl;
cout<<"\t\t\t\t///////////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\tQuiz Game Project in C++\n"<<endl;
cout<<"\t\t\t\t///////////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
inline void Quiz_game::player_info() /*concept of declearing member functions outside the class*/
{
cout<<"\t\t1.Enter the player name here:";
getline(cin,name);
cout<<endl;
cout<<"\t\t2.Enter your current address here:";
getline(cin,address);
cout<<endl;
cout<<"\t\tWelome in my quiz game"<<endl;;
cout<<endl;
cout<<"\t\tThanks Dear "<<name<<" for choising this game"<<endl;
cout<<"\n\n\n";
}
class instruction //this is the second class for the user instruction
{
public:
void instruct() //this function is define inside the class
{
cout<<"\t\t\t\tinstructions:"<<endl;
cout<<endl;
cout<<"\t\tthere are some following instruction for this game:"<<endl;
cout<<"\t\tplease read the instructions carefully."<<endl;
cout<<"\t\t1.this game is for the c++ students."<<endl;
cout<<"\t\t2.you have 9 Leavel in this game."<<endl;
cout<<"\t\t3.each Leavel have the 5 MCQ'S based question."<<endl;
cout<<"\t\t4.if you give the ture answer you will won the 10 coins."<<endl;
cout<<"\t\t5.if your coins amount after playing level will be 50 the you win the level"<<endl;
cout<<"\t\t6.you can play one level in one game."<<endl;
cout<<"\t\t7.GOOD luck.\n\n "<<endl;
cout<<"\t\t\t\tif you want to start this game(press s key):";
}
};
class level:public Quiz_game //here the level class inherit with level class /*concept of inheritence*/
{
public:
void top_menu();
void level_menu();
};
void level::top_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\tLEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void level::level_menu()
{
cout<<"\t\t\tDear "<<name<<"you have choice one level at a time"<<endl;
cout<<endl;
cout<<"--------- ***************************************************************---------"<<endl;
cout<<"|Level 1| ***************************************************************|Level 9|"<<endl;
cout<<"--------- ***************************************************************---------"<<endl;
cout<<"\t---------**********************************************---------"<<endl;
cout<<"\t|Level 2|**********************************************|Level 8|"<<endl;
cout<<"\t---------**********************************************---------"<<endl;
cout<<"\t\t---------***************************---------"<<endl;
cout<<"\t\t|Level 3|***************************|Level 7|"<<endl;
cout<<"\t\t---------***************************---------"<<endl;
cout<<"\t\t\t---------*********---------"<<endl;
cout<<"\t\t\t|Level 4|*********|Level 6|"<<endl;
cout<<"\t\t\t---------*********---------"<<endl;
cout<<"\t\t\t\t---------"<<endl;
cout<<"\t\t\t\t|Level 5|"<<endl;
cout<<"\t\t\t\t---------"<<endl;
cout<<"\n\n";
}
class first_level
{
protected:
int pic;
int count=0;
public:
void first_level_menu();
void first_level_questions();
};
void first_level::first_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t1st LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void first_level::first_level_questions()
{
cout<<"Q.1:which of the following is not the member of class?"<<endl;
cout<<"1) static function"<<" "<<"2)friend function"<<endl;
cout<<"3) const function"<<" "<<"4)virtual function"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:which of the following is the correct class of the object cout?"<<endl;
cout<<"1) iostream"<<" "<<"2)istream"<<endl;
cout<<"3) ostream"<<" "<<"4)ifstream"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:which of the following cannot be used with keyword virtual?"<<endl;
cout<<"1) class"<<" "<<"2)member function"<<endl;
cout<<"3) constructor"<<" "<<"4)destructor"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:which of the following keyword is used to overload an operator?"<<endl;
cout<<"1) overload"<<" "<<"2)operator"<<endl;
cout<<"3) friend"<<" "<<"4)override"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:which of the following access specifier is used as a default in class?"<<endl;
cout<<"1) public"<<" "<<"2)protected"<<endl;
cout<<"3) friend"<<" "<<"4)private"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class second_level : public first_level
{
public:
void second_level_menu();
void second_level_questions();
};
void second_level::second_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t2nd LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void second_level::second_level_questions()
{
cout<<"Q.1:How many types of polymorphisms are supported by c++?"<<endl;
cout<<"1) one"<<" "<<"2)two"<<endl;
cout<<"3) three"<<" "<<"4)four"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:which of the following way are legal to access a class data member using this pointer?"<<endl;
cout<<"1) this->x"<<" "<<"2)this.x"<<endl;
cout<<"3) *this.x"<<" "<<"4)*this-x"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:which of the following operator cannot be overloaded?"<<endl;
cout<<"1) []"<<" "<<"2)->"<<endl;
cout<<"3) ?:"<<" "<<"4)*"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:which type is used in the class given below?\nclass A:public X, public Y"<<endl;
cout<<"1) multilevel inheritence"<<" "<<"2)multiple inheritence"<<endl;
cout<<"3) single inheritence"<<" "<<"4)hybrid inheritence"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:which of the following provide a reuse mechanism?"<<endl;
cout<<"1) Abstraction"<<" "<<"2)inheritance"<<endl;
cout<<"3) Dynamic binding"<<" "<<"4)Encapsulation"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class third_level:public first_level
{
public:
void third_level_menu();
void third_level_questions();
};
void third_level::third_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t3ed LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void third_level::third_level_questions()
{
cout<<"Q.1:which of the following statment is correct?"<<endl;
cout<<"1) class is an instant of object"<<" "<<"2)object is an instant of class"<<endl;
cout<<"3) class is an instant of data type"<<" "<<"4)none of these"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:which of the following is used to define the member of a class externally?"<<endl;
cout<<"1) :"<<" "<<"2)::"<<endl;
cout<<"3) #"<<" "<<"4)none of these"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:is c++ is fully object oriented programming?"<<endl;
cout<<"1) ture"<<" "<<"2)false"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:can a class declear or define inside another class?"<<endl;
cout<<"1) yes"<<" "<<"2)no"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:private member of the class are accessible only the member of the same class?"<<endl;
cout<<"1) ture"<<" "<<"2)false"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class fourth_level:public first_level
{
public:
void fouth_level_menu();
void fourth_level_questions();
};
void fourth_level::fouth_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t4th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void fourth_level::fourth_level_questions()
{
cout<<"Q.1:The order in which operands are evaluated in an expression is predictable if the operator is?"<<endl;
cout<<"1) Addition"<<" "<<"2)Modulus"<<endl;
cout<<"3) Multiply"<<" "<<"4)&&"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:is a relationship in c++ is?"<<endl;
cout<<"1) inheritance"<<" "<<"2)encapulation"<<endl;
cout<<"3) compution"<<" "<<"4)none of these"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:Which of the following correctly describes overloading of functions??"<<endl;
cout<<"1) Virtual polymorphism "<<" "<<"2)Transient polymorphism"<<endl;
cout<<"3)Ad-hoc polymorphism "<<" "<<"4)Pseudo polymorphism"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:What is meant by multiple inheritance?"<<endl;
cout<<"1) Deriving a base class from derived class"<<" "<<"2) Deriving a derived class from base class"<<endl;
cout<<"3)Deriving a derived class from more than one base class "<<" "<<"4)none"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:Can we pass parameters to base class constructor though derived class or derived class constructor?"<<endl;
cout<<"1)yes "<<" "<<"2)no"<<endl;
cout<<"3) may be"<<" "<<"4)none"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class five_level:public first_level
{
public:
void five_level_menu();
void five_level_questions();
};
void five_level::five_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t5th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void five_level::five_level_questions()
{
cout<<"Q.1Which of the followings is/are automatically added to every class, if we do not write our own:?"<<endl;
cout<<"1) Copy Constructor"<<" "<<"2) Assignment Operator"<<endl;
cout<<"3)A constructor without any parameter "<<" "<<"4)all of above"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:Which of the following gets called when an object is being created??"<<endl;
cout<<"1) constructor"<<" "<<"2)destructor"<<endl;
cout<<"3) virtual function"<<" "<<"4)main"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:Destructor has a same name as the constructor and it is preceded by?"<<endl;
cout<<"1) !"<<" "<<"2)~"<<endl;
cout<<"3) @"<<" "<<"4)$"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:Like constructors, can there be more than one destructors in a class??"<<endl;
cout<<"1) yes"<<" "<<"2)may be"<<endl;
cout<<"3) not say"<<" "<<"4)no"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:A friend class can access members of other class in which it is declared as friend.?"<<endl;
cout<<"1) private"<<" "<<"2)protected"<<endl;
cout<<"3) public"<<" "<<"4)1 & 2"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class six_level:public first_level
{
public:
void six_level_menu();
void six_level_questions();
};
void six_level::six_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t6th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void six_level::six_level_questions()
{
cout<<"Q.1:Which keyword is used to represent a friend function?"<<endl;
cout<<"1) friend"<<" "<<"2)Friend"<<endl;
cout<<"3)friend_func "<<" "<<"4)Friend_func"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:Where does keyword ‘friend’ should be placed??"<<endl;
cout<<"1)function defination "<<" "<<"2)function declearation"<<endl;
cout<<"3) main function"<<" "<<"4)block function"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:While overloading binary operators using member function, it requires ___ argument??"<<endl;
cout<<"1) 0"<<" "<<"2)1"<<endl;
cout<<"3) 4"<<" "<<"4)2"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:Which of the following operator functions cannot be global, i.e., must be a member function.?"<<endl;
cout<<"1)new "<<" "<<"2)delete"<<endl;
cout<<"3)conversion operator "<<" "<<"4)all of above"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:How many specifiers are present in access specifiers in class?"<<endl;
cout<<"1) 6"<<" "<<"2)8"<<endl;
cout<<"3) 4"<<" "<<"4)3"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:";
}
}
class seven_level:public first_level
{
public:
void seven_level_menu();
void seven_level_questions();
};
void seven_level::seven_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t7th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void seven_level::seven_level_questions()
{
cout<<"Q.1:A class is made abstract by declaring at least one of its functions as?"<<endl;
cout<<"1) impure virtual function"<<" "<<"2) pure virtual function"<<endl;
cout<<"3) pure abstract function"<<" "<<"4)impure abstract function"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:It is not possible to combine two or more file opening mode in open () method.?"<<endl;
cout<<"1)yes "<<" "<<"2)no"<<endl;
cout<<"3) may be"<<" "<<"4)cannot say"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:Which of the following methods can be used to open a file in file handling?"<<endl;
cout<<"1) using open()"<<" "<<"2)constructor"<<endl;
cout<<"3) destructor "<<" "<<"4)both A and B"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:Which operator is used to insert the data into file?"<<endl;
cout<<"1) >>"<<" "<<"2)<<"<<endl;
cout<<"3) <"<<" "<<"4)none"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:Which of the following is the correct way to declare a pointer?"<<endl;
cout<<"1) int *ptr"<<" "<<"2)int ptr"<<endl;
cout<<"3) int&ptr"<<" "<<"4)all of above"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:"<<endl;
}
}
class eight_level:public first_level
{
public:
void eight_level_menu();
void eight_level_questions();
};
void eight_level::eight_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t8th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void eight_level::eight_level_questions()
{
cout<<"Q.1:Which operator is used to signify the namespace in c++??"<<endl;
cout<<"1) conditional operator"<<" "<<"2)ternary operator"<<endl;
cout<<"3) scope operator "<<" "<<"4)none of these"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:What is the general syntax for accessing the namespace variable??"<<endl;
cout<<"1)namespace::operator"<<" "<<"2)namespace,operator"<<endl;
cout<<"3) namespace$operator"<<" "<<"4)namespace#operator"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:The use of Namespace is to structure a program into logical units??"<<endl;
cout<<"1) ture"<<" "<<"2)false"<<endl;
cout<<"3)may be "<<" "<<"4)cannot say"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:Which value is placed in the base class??"<<endl;
cout<<"1) drived valuse"<<" "<<"2)default type values"<<endl;
cout<<"3)Both default type & derived values "<<" "<<"4)none"<<endl;
cin>>pic;
if(pic==2)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5: What is a template??"<<endl;
cout<<"1) A template is a formula for creating a generic class"<<" "<<"2)A template is used to manipulate the class"<<endl;
cout<<"3) A template is used for creating the attributes"<<" "<<"4)none"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:"<<endl;
}
}
class nine_level:public first_level
{
public:
void nine_level_menu();
void nine_level_questions();
};
void nine_level::nine_level_menu()
{
cout<<"\t\t\t\t///////////////////////////////////\n"<<endl;
cout<<"\t\t\t\t\t9th LEVEL OF QUIZ GAME\n"<<endl;
cout<<"\t\t\t\t//////////////////////////////////\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\tThis Game is Made By HAMZA REHMAN"<<endl;
cout<<"\t\t\t\t\t\t\t\t\t\t*---------------------------------*\n\n"<<endl;
}
void nine_level::nine_level_questions()
{
cout<<"Q.1:Which of the following best defines the syntax for template function?"<<endl;
cout<<"1)template return_type Function_Name(Parameters) "<<" "<<"2)template return_type Function_Name(Parameters)"<<endl;
cout<<"3)A and B "<<" "<<"4)none of these"<<endl;
cin>>pic;
if(pic==3)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.2:Templates are abstract recipe for producing a concrete code, and it is used for?"<<endl;
cout<<"1)producing functions "<<" "<<"2)producing classes"<<endl;
cout<<"3) none"<<" "<<"4)both A and B"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.3:How many parameters are legal for non-type template??"<<endl;
cout<<"1) 1"<<" "<<"2)6"<<endl;
cout<<"3) 5"<<" "<<"4)4"<<endl;
cin>>pic;
if(pic==4)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.4:How many kinds of entities are directly parameterized in c++??"<<endl;
cout<<"1) 3"<<" "<<"2)8"<<endl;
cout<<"3) 7"<<" "<<"4)1"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
cout<<"Q.5:Can we have overloading of the function templates??"<<endl;
cout<<"1)yes "<<" "<<"2)no"<<endl;
cout<<"3)cannot say "<<" "<<"4)may be"<<endl;
cin>>pic;
if(pic==1)
{
cout<<"your answer is correct you win 10 coins"<<endl;
count=count+10;
cout<<"total amount of coins is:"<<count<<endl;
}
else
{
cout<<"your answer is wrong"<<endl;
}
cout<<endl;
if(count==50)
{
cout<<endl;
cout<<"\t\tcongratulation you won this level:"<<endl;
cout<<"\t\tyour total amount of coins:"<<count<<endl;
}
else
{
cout<<"sorry you lose this level kindly try again:"<<endl;
}
}
int main()
{
first_level obj4;
second_level obj5;
third_level obj6;
fourth_level obj7;
five_level obj8;
six_level obj9;
seven_level obj10;
eight_level obj11;
nine_level obj12;
int choice_level;
char choice;
instruction obj2;
level obj3;
Quiz_game obj1; //here we make the object of main class /*concept of object*/
obj1.menu(); //calling member function with the use of objects
obj1.player_info(); //calling member function with the use of objects
jump:
cout<<"\t\t\t\tHello,Dear Do you want to play this Game(y/n)?";
cin>>choice;
if(choice=='y' || choice=='Y')
{
system("cls");
obj1.menu();
obj2.instruct();
}
else if(choice=='n' || choice=='N')
{
cout<<"thanks for playing this game"<<endl;
}
else
{
cout<<"invalid input:"<<endl;
goto jump;
}
cin>>choice;
system("cls");
obj3.top_menu();
obj3.level_menu();
again_jump:
cout<<"\t\t\t\twhat level would you like to play enter your choice:";
cin>>choice_level;
switch(choice_level)
{
case 1:
system("cls");
obj4.first_level_menu();
obj4.first_level_questions();
break;
case 2:
system("cls");
obj5.second_level_menu();
obj5.second_level_questions();
break;
case 3:
system("cls");
obj6.third_level_menu();
obj6.third_level_questions();
break;
case 4:
system("cls");
obj7.fouth_level_menu();
obj7.fourth_level_questions();
break;
case 5:
system("cls");
obj8.five_level_menu();
obj8.five_level_questions();
break;
case 6:
system("cls");
obj9.six_level_menu();
obj9.six_level_questions();
break;
case 7:
system("cls");
obj10.seven_level_menu();
obj10.seven_level_questions();
break;
case 8:
system("cls");
obj11.eight_level_menu();
obj11.eight_level_questions();
break;
case 9:
system("cls");
obj12.nine_level_menu();
obj12.nine_level_questions();
break;
default:
cout<<"this game has only 9 level"<<endl;
goto again_jump;
break;
}
}
No comments:
Post a Comment