This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
PRACTICAL TRAINING
TOPIC : GAMING IN C++ (KAUN BANEGA CROREPATI)
FACULTY GUIDE : Ms. ANJU MISHRA
STUDENT DETAILS
1. PERONICA SINGH 2. NUPUR SINHA
A2305308082 A2305308083
B.TECH IT (2008-2012) B.TECH IT (2008-2012)
4IT2X 4IT2X
3. PRAGYA BAJAJ 4. JIGYASSA VIRMANI
A2305308084 A2305308088
B.TECH IT (2008-2012) B.TECH IT (2008-2012)
4IT2X 4IT2X
AMITY SCHOOL OF ENGINEERING AND TECHNOLOGY
1
ACKNOWLEDGEMENTS
I owe a great many thanks to a great many people who helped and supported me during this
project .
My deepest thanks to Ms. Anju Mishra ,lecturer, ASET ,Amity University Noida the Guide of the project for guiding and correcting various documents of mine with attention and care. She has taken pain to go through the project and make necessary correction as and when needed.I express my thanks to the director general Ms.Balvinder Shukla,Amity U niversity , Noida for extending his support. I would also thank my Institution and my faculty members without whom this project would have been a distant reality
2
ABSTRACT
The objective of the project is to illustrate the features of C++ as well as object-oriented
programming concepts.
C++ is a statically typed , free-form, multi-paradigm, compiled, general-purpose
programming language. It is regarded as a "middle-level" language, as it comprises a
combination of both high-level and low-level language features.
As one of the most popular programming languages ever created, C++ is widely used in the
software industry. Some of its application domains include systems software, application
software, device drivers, embedded software, high-performance server and client
applications, and entertainment software such as video games. Several groups provide both
free and proprietary C++ compiler software, including the GNU Project, Microsoft, Intel and
Borland. C++ has greatly influenced many other popular programming languages, most
notably Java.
KAUN BANEGA CROREPATI -A project in C++, In this project use of graphics, arrays
and of course object oriented approach. The questions are stored in arrays which are
displayed on the interface randomly. There is excessive use of strings manipulation.
void probar(){cleardevice();setcolor(4);settextstyle(6,0,3);outtextxy(250,180,"! L O A D I N G !");outtextxy(250,300," PLEASE WAIT");for(int i=0;i<350;i++){rectangle(500,250,150+i,260);delay(4);}}
13
void welcome(){cleardevice(); //clears graphic screensetcolor(WHITE);setbkcolor(0); //background colorsettextstyle(4,0,4); //for font style n sizeouttext("AMITY UNIVERSITY NOIDA");settextstyle(3,0,2);setcolor(1);outtextxy(160,280,"Project By :"); //for viewing text in graphic moodouttextxy(222,300,"PERONICA SINGH");outtextxy(222,320,"NUPUR SINHA");outtextxy(222,340,"PRAGYA BAJAJ");outtextxy(222,360,"JIGYASA VIRMANI");getch();cleardevice();setcolor(RED);settextstyle(7,0,4); //for font style n sizeouttextxy(110,120,"HELLO");delay(800);outtextxy(130,160,"WELCOME TO KAUN BANEGA CROREPATI");delay(800);settextstyle(7,0,2);setcolor(WHITE);outtextxy(300,430,"*** Press any key to START ***");getch();}
class que{ friend class questset;
private:
char *s1,*s2,*s3,*s4,*s5; char c1; char* correct; int ch;
class questset{private: que f[26]; int ko; double m; //money
public:questset() { m=10000; }
void setMoney() { m=m*2; if (m==10000000) { cout<<"THANKS 4 PLAYING"; getch(); exit(0); } }double getMoney() { return m; }
int answer() { char k; int x,y,z; cout<<"enter option"<<endl; cin>>k; if(k==f[ko].c1){ cout<<"correct answer "<<endl; cout<<"you have won RS"<<getMoney()<<endl; getch(); clrscr();
f[15].s1="Which indian bank has the largets number of branches in the world";
f[15].s2="A) bank of baroda"; f[15].s3="B) allahabad bank"; f[15].s4="C) state bank of india"; f[15].s5="D) union bank of india"; f[15].c1='c'; f[15].correct="state bank of india";
f[16].s1="Which indian city was originally known as kapila;";
f[25].s2="Currecy chest"; f[25].s3="Meduim of exchange"; f[25].s4="Standard of postponed payments"; f[25].s5="Standard of Money"; f[25].c1='b'; f[25].correct="Meduim of exchange";
}
void user_details() { char name[20],city[20], state[20]; char dream[600]; cout<<"Please enter your name "<<endl; cin>>name; cout<<"Please enter the city to which you belong "<<endl; cin>>city; cout<<"Please enter the state to which you belong "<<endl; cin>>state; }
void rules() { clrscr(); cout<<"\n\n\n\t\t RULES FOR PLAYING THE GAME\n\n\n "<<endl; cout<<"\t1. You will be facing 05 questions starting from Rs.100 "<<endl; cout<<"\t2. There would be a safe point i.e. after SECOND Question"<<endl; cout<<"\t3. To assist you there will be THREE LIFELINES "<<endl; cout<<"\t a) 50 : 50 b) Audience Poll c) Flip Question "<<endl; cout<<"\t4. The above mentioned lifelines can only be used once "<<endl; cout<<"\t5. You can quit the game at any instant "<<endl; cout<<"\n\n\n\t\t HOW TO PLAY THE GAME\n\n"<<endl; cout<<"\t1. For answering a question enter the option as A or B or C or D "<<endl; cout<<"\t2. For Quiting the game press 0 "<<endl; cout<<"\t3. For using the lifeline 50-50 press 1 "<<endl; cout<<"\t4. For the Audience Poll press 2 "<<endl; cout<<"\t5. For Flipping the question press 3 "<<endl; cout<<endl; cout<<" !!! press enter to continue!!!"<<endl;
As specified above, the system is first divided in units which are developed and tested for
their functionalities. These units are integrated into a complete system during Integration
phase and tested to check if all modules/units coordinate between each other and the system
as a whole behaves as per the specifications. After successfully testing the software, it is
delivered to the customer.
Although the source code in your file is somewhat cryptic, and anyone who doesn't know C+
+ will struggle to understand what it is for, it is still in what we call human-readable form.
Your source code file is not a program, and it can't be executed, or run, as a program can.
To turn your source code into a program, you use a compiler. How you invoke your compiler,
and how you tell it where to find your source code, will vary from compiler to compiler;
check your documentation. In Borland's Turbo C++ you pick the RUN menu command or
type tc <filename>
After your source code is compiled, an object file is produced. This file is often named with
the extension .OBJ. This is still not an executable program, however. To turn this into an
executable program, you must run your linker. C++ programs are typically created by linking
together one or more OBJ files with one or more libraries
The steps to create an executable file are
1. Create a source code file, with a .CPP extension.
2. Compile the source code into a file with the .OBJ extension.
3. Link your OBJ file with any needed libraries to produce an executable
program.
3.g. Operations & Maintenance
26
This phase of "The Waterfall Model" is virtually never ending phase (Very long). Generally,
problems with the system developed (which are not found during the development life cycle)
come up after its practical use starts, so the issues related to the system are solved after
deployment of the system. Not all the problems come in picture directly but they arise time to
time and needs to be solved; hence this process is referred as Maintenance.
3.h. Disadvantages of the Waterfall Model.
As it is very important to gather all possible requirements during the Requirement
Gathering and Analysis phase in order to properly design the system, not all
requirements are received at once, the requirements from customer goes on getting
added to the list even after the end of "Requirement Gathering and Analysis" phase,
this affects the system development process and its success in negative aspects.
The problems with one phase are never solved completely during that phase and in
fact many problems regarding a particular phase arise after the phase is signed off,
this results in badly structured system as not all the problems (related to a phase) are
solved during the same phase.
The project is not partitioned in phases in flexible way.
As the requirements of the customer goes on getting added to the list, not all the
requirements are fulfilled, this results in development of almost unusable system.
These requirements are then met in newer version of the system; this increases the
cost of system development.
27
4. VALIDATIONS
he project has also some validation rules, which a user must know before running it.
Even if the program is user friendly it would not work well in every cases. T First of all if a user chooses an option other than the menu, he or she will be prompted
an error massage.
Answer code option cannot be other than a, b, c & d [A, B, C & D is also valid].
Any field of the file cannot be left blank.
An individual do not have the privilege to change the question number of a question
as it is generated automatically.
An individual do not have the privilege to skip any question or options when he is
adding some question in the run time.
A player cannot skip a question without terminating the program at the time when he
is playing the game show.
These are the main validations that are given to the program. The supervisor and its
associates must know these validations, so that they can easily monitor the outstanding
features that are been incorporated in the program
28
5. Results
C++ Best suited for general purpose and low level programming. It is the right choice for
anyone interested in programming in the next decade. C++ provides the tools of object-
oriented programming and the performance of a systems-level language, which makes C++
the development language of choice.
Here are some advantages and disadvantages of C ++
5.a. Advantages:
Extremely fast
Works very well for GUI programming on a computer.
Good language to write operating systems, drivers, and platform dependent
applications with.
Good language to learn to program with.
Good language for engineers.
5.b.Disadvantages
Although it is platform independent, it is mostly used for platform specific
applications.
A library set is usually chosen that locks you into a single platform or
operating system.
Overly complex for very large high level programs.
Overly complex and difficult to debug when used for web applications.
Marketable skills are low level programming, vendor software, and video
games, making it difficult to find jobs unless you have are very advanced in a
target area.
29
6.Comparison of C++ with other languages
In time, higher-level languages evolved, such as BASIC and COBOL. These languages let
people work with something approximating words and sentences, such as Let I = 100. These
instructions were translated back into machine language by interpreters and compilers. An
interpreter translates a program as it reads it, turning the program instructions, or code,
directly into actions. A compiler translates the code into an intermediary form. This step is
called compiling, and produces an object file. The compiler then invokes a linker, which
turns the object file into an executable program.Because interpreters read the code as it is
written and execute the code on the spot, interpreters are easy for the programmer to work
with. Compilers, however, introduce the extra steps of compiling and linking the code, which
is inconvenient. Compilers produce a program that is very fast each time it is run. However,
the time-consuming task of translating the source code into machine language has already
been accomplished.
Another advantage of many compiled languages like C++ is that you can distribute the
executable program to people who don't have the compiler. With an interpretive language,
you must have the language to run the program.
For many years, the principle goal of computer programmers was to write short pieces of
code that would execute quickly. The program needed to be small, because memory was
expensive, and it needed to be fast, because processing power was also expensive. As
computers have become smaller, cheaper, and faster, and as the cost of memory has fallen,
these priorities have changed. Today the cost of a programmer's time far outweighs the cost
of most of the computers in use by businesses.
Well-written, easy-to-maintain code is at a premium. Easy- to-maintain means that as
business requirements change, the program can be extended and enhanced without great
expense.
30
But the current version of Standard C++ provides no language features to create multi-
threaded software. These facilities are present in some other languages including Java, Ada ,
and C# . It is possible to use operating system calls or third party libraries to do multi-
threaded programming, but both approaches may create portability concerns. The new C++0x
standard addresses this matter by extending the language with threading facilities.
C++ is also sometimes compared unfavourably with languages such as Smalltalk, Java, or
Eiffel on the basis that it enables programmers to "mix and match" object-oriented
declarative programming, and others, rather than strictly enforcing a single style, although
C++ is intentionally a multi-paradigm language. C++ is commonly criticized for lacking built
in garbage collection.
31
7. Conclusion
The objective of the project was to illustrate the features of C++ as well as object-oriented programming concepts with the help of a gaming program. What can be done with C++ which cannot be done with other programming languages has been explained and illustrated. The importance of C++ has been emphasized and the reasons why C++ been popular is listed down-
It supports all features of both structured programming and object oriented programming.
It gives us the easiest way to handle the data hiding and encapsulation with help of powerful keywords class, public, private and protected.
It introduces key concepts such as inheritance, polymorphism, abstraction.
It provides overloading of operators and functions.
Exception handling is done by the extra keywords namely try,catch and throw
Provides friends, static methods constructors destructors for class objects.
It is a Extremely fast
C++ Best suited for general purpose and low level programming. It is the right choice for
anyone interested in programming in the next decade.
32
8. References
Programming in C++ by D Ravichandran (second edition)
C++ by Sumita Arora(second edition)
Programming in C++ by E Balgurusamy
http://www.cprogramming.com/tutorial.html
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/
More Effective C++: 35 New Ways To improve your program and design
C++ The Complete Reference Third Edition, Herbert Schildt, Publisher: Osborne