Nuclear Concept in C++
Nuclear Concept in C++
Nuclear Concept in C++
“computer science”
Compiled by:
Ayushi Agarwal
Introduction
C++ is a computer language but with a difference.
C++ designers have borrowed the best features of many existing
languages as c, c# etc. and added a few new features to form a
simple easy to learn and an object oriented language. C++ adds
a concept called “operator overloading” not seen in the earlier
OOP languages and it makes the creation of libraries much
cleaner
Detailed information
Includes animations
Colorful presentation
Setup change options
Easy and convenient to use
As fast as possible
User friendly
Safe for the user
Acknowledgem
ent
It was really a great opportunity for
me to make this project work on the respective topic. I
would like to wholeheartedly thank my respected
computer teacher MrsKESARWANI MAM for providing
me such a great opportunity. I am indebted to MAMwho
took great pains in going through the entire manuscript
and made valuable comments.
______________
_______________
Teacher’s signature
Invigilator’s signature
IT’S HISTORY:
FEATURES OF C++:
• Character sets:-
• Tokens
• Variables
A variable is one which hold certain values. It is a sequence of
alphabets and digits but the first alphabet must be an alphabet
or an underscore.
• Constant
• Data Types
1. Simple/fundamental
2. Pointers
3. Structured/derived
4. Void type
5. Enumerated
Character
In C++ we can define our own data type and specify what
values a variable of this type can take. The data type defined this
way is known as enumerated data type. enumerated data type
helps in enhancing the readability of the code.
PREPROCESSOR DIRECTIVES:
OBJECT ORIENTED
PROGRAMMING
Object oriented programming (OOP) is
programming language model which is organized around object
rather than actions and data rather than logic. OOP deals with
the overall program organization than the details of program
operation. It gives more emphasis on data, provides extensibility
and models of real world problem very well. A computer is said
to be object oriented if it supports four specific properties called
abstraction, polymorphism, inheritance, and encapsulation.
DATA ABSTRACTION
As the word indicates abstraction refers to the
representation of only the essential features of the real world
object in the program object. This process does not include the
background details and explanations. This concept of abstraction
is used in classes. A class is thus defined as a list of abstract
attributes and functions which operate on these attributes. This
term abstract data types (ADT) is used to refer classes due to
this reason.
Encapsulation
In object oriented programming , objects interact with
each other by message. The only thing that an object knows
about another is the object’s interface. Each object’s data and
logic is hidden from other’s object. In other words, the interface
encapsulates the object’s code and data.
INHERITANCE
Classes that inherit from a class are class subclasses. The classes
that inherit from a class are called superclasses. In the example
student is a superclass for graduate and undergraduate.
Graduate and undergraduate are subclasses of student.
Subclasses provide specialized behaviors from the basis of the
common elements provided by the superclass. Programmers can
implement superclasses called abstract classes that define
common behaviors.
OBJECT ORIENTED
PROGRAMMING vs.
PROCEDURAL PROGRAMMING
#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
#include<graphics.h>
#include<fstream.h>
#include<stdlib.h>
#include<MPOINT.CPP>
int button,m,n;
int x3[10], y3[10], rad[10], col[10],x1[10],y1[10],
x2[10], y2[10];
class LAYOUT{
MPOINT mptr;
public:
LAYOUT(){
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
counter=1;
int x,y;
x=getmaxx();
y=getmaxy();
mptr.restrictmouseptr(1,1,x-1,y-1);
mptr.showmouseptr();
}
int counter;
void start_it();
void end_it();
public:
void showButtons(){
button_3d(15,425,65,450,0,"MORE",1);
button_3d(222,456,385,475,0,"MAIN MENU",1);
button_3d(530,425,580,450,0,"EXIT",1);
}
void button_3d(int x1,int y1,int x2,int y2,int check,char* text,int
color)
{
int up,low;
setfillstyle(1,7);
bar(x1,y1,x2,y2);
if(check==0)
up=15,low=8;
else
up=8,low=15;
setcolor(low);
line(x2,y1,x2,y2);
line(x2-1,y1,x2-1,y2);
line(x1,y2,x2,y2);
line(x1+1,y2-1,x2,y2-1);
setcolor(up);
line(x1,y1,x2,y1);
line(x1+1,y1+1,x2-1,y1+1);
line(x1,y1,x1,y2);
line(x1+1,y1+1,x1+1,y2-1);
setcolor(color);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(x1+(x2 - x1)/2,(y1+(y2 - y1)/2)-2, text);
}
};
void LAYOUT::end_it()
{settextstyle(7,0,3);
if((button&1) && (n>=530 && n<=580) && (m>=425 &&
m<=450))
{
setbkcolor(RED); cleardevice();
while(!kbhit())
{
for(int r=0;r<10;r++)
{
x3[r]=random(640);
y3[r]=random(480);
rad[r]=random(50);
col[r]=random(15);
x1[r]=random(640);
y1[r]=random(480);
x2[r]=random(640);
y2[r]=random(480);
}
for(r=0;r<10;r++)
{
setcolor(col[r]);
outtextxy(x3[r],y3[r],"PHYSICS");
outtextxy(x1[r],y1[r],"NUCLEAR");
}
setcolor(RED);
delay(100);
for(r=0;r<10;r++)
{
outtextxy(x3[r],y3[r],"PHYSICS");
outtextxy(x1[r],y1[r],"NUCLEAR");
}
}
void LAYOUT::start_it()
{ setbkcolor(6);
int x,y,h;
for(int lp=1;lp<8;lp++)
{ if(lp==6)lp=7;
for(x=0;x<=100;x++)
{
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(2);
settextstyle(1,0,4);
setusercharsize(x,6,x,3);
setcolor(14);
moveto(300,100);
outtext("__");
setcolor(6);
moveto(300,100);
outtext("< >");
if(x<90)
{// sound(frec+=10);
delay(lp);}
else
{// sound(frec+=10);
delay(1+lp);
}
}
nosound();
for(y=0;y<=100;y++)
{
setcolor(lp);
settextstyle(1,0,4);
setusercharsize(y,6,y,3);
moveto(300,100);
outtext("__");
moveto(300,100);
outtext("< >");
}
}
for(x=0;x<=100;x++)
{
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(9);
settextstyle(1,0,4);
setusercharsize(x,6,x,3);
setcolor(8);
moveto(300,100);
outtext("__");
setcolor(9);
moveto(300,100);
outtext("< >");
if(x<90)
{// sound(frec+=10);
delay(20);}
else
{// sound(frec+=10);
delay(20);
}
}
nosound();
for(y=0;y<=100;y++)
{
setcolor(0);
settextstyle(1,0,4);
setusercharsize(y,6,y,3);
moveto(300,100);
outtext("__");
moveto(300,100);
outtext("< >");
if(y>20)
{
settextstyle(7,0,1);
setusercharsize(y-20,45,y-20,40);
setcolor(10);
outtext("NUCLEAR PHYSICS");
setcolor(2);
outtext("___________");
delay(10);
if(y<100)
{
settextstyle(7,0,1);
setusercharsize(y-20,45,y-20,40);
setcolor(0);
outtext("NUCLEAR PHYSICS");
}
}
}
//delay(1000);
settextstyle(3,0,2);
delay(50);
setcolor(9);
outtextxy(150,300,"CREATED BY:-");
//x=10,y=10;
setcolor(WHITE);
settextstyle(1,0,4);
outtextxy(335,375,"PRANJAL AND OAJASAVEE");
MPOINT.CPP
#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
#include<graphics.h>
#include<fstream.h>
#include<stdlib.h>
class MPOINT
{
public:
int button,m,n;
union REGS i,o,a,b;
int intmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void restrictmouseptr(int x,int y,int x1,int y1)
{
i.x.ax=7;
i.x.cx=x;
i.x.dx=x1;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y;
i.x.dx=y1;
int86(0x33,&i,&o);
}
void getmousepos(int *p,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*p=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
};
/*void main(){
int button,m,n;
MPONIT x;
int gd=DETECT,gm;
initgraph(&gd,&gm,"\\tc\\bgi");
x.getmousepos(&button,&m,&n);
x.showmouseptr();
cout<<m;
getch();
} */
SETUP.CPP
#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
#include<graphics.h>
#include<fstream.h>
#include<stdlib.h>
int ctmbgcolor;
int ctmfntcolor;
//1:BG
//2:FONT
int clrType;
void setDefaultBG(){
ctmbgcolor=6;
}
void setBGColor(int clr){
ctmbgcolor =clr;
}
int getBGColor(){
return ctmbgcolor;
}
int getFontcolor(){
return ctmfntcolor;
}
void setFontcolor(int clr){
ctmfntcolor=clr;
}
void setDefaultFontClr(){
ctmfntcolor=15;
}
int button_s,m_s,n_s;
union REGS i,o,a,b;
int intmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void restrictmouseptr(int x,int y,int x1,int y1)
{
i.x.ax=7;
i.x.cx=x;
i.x.dx=x1;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y;
i.x.dx=y1;
int86(0x33,&i,&o);
}
void getmousepos(int *p,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*p=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
setcolor(up);
line(x1,y1,x2,y1);
line(x1+1,y1+1,x2-1,y1+1);
line(x1,y1,x1,y2);
line(x1+1,y1+1,x1+1,y2-1);
setcolor(color);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(x1+(x2 - x1)/2,(y1+(y2 - y1)/2)-2, text);
}
void repaintButton(int i);
void paintButtons(int chkNum){
int x1,y1,x2,y2,chk;
chk=0;
for (int i=1;i<17;i++)
{
if(i<=4)
{
x1=20+100*i;
x2=110+100*i;
y1=10;
y2=110;
}
if(i>4&&i<=8)
{
x1=20+100*(i-4);
x2=110+100*(i-4);
y1=120;
y2=220;
}
if(i>8&&i<=12)
{
x1=20+100*(i-8);
x2=110+100*(i-8);
y1=230;
y2=330;
}
if(i>12)
{
x1=20+100*(i-12);
x2=110+100*(i-12);
y1=340;
y2=440;
}
if(chkNum==i)
{
chk=1;
}
else{
chk=0;
}
button_3d(x1,y1,x2,y2,chk,"A",i-1,1);
}
button_3d(250,450,350,470,0,"Done",9,0);
}
void pickColor(){
//setDefaultBG();
//setDefaultFontClr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
clrType=3;
int button,m,n,num_button;
settextstyle(7,0,3);
button_3d(40,86,581,110,0, " Change Background Color ",1,0)
;
button_3d(40,124,581,148,0," Change Font Color ",1,0) ;
button_3d(40,162,581,186,0," Back ",1,0) ;
getmousepos(&button,&n,&m);
gotoxy(1,1);
int z,zz;
z=1;
zz=1;
int x,y;
x=getmaxx();
y=getmaxy();
restrictmouseptr(1,1,x-1,y-1);
showmouseptr();
setbkcolor(0);
settextstyle(15,0,1);
outtextxy(20,30,"Select BG");
int d;
while(z){
//cleardevice();
getmousepos(&button,&n,&m);
if((button&1) && (n>=40 && n<=581) && (m>=86 &&
m<=110))
{
//BG
clrType=1;
}
if((button&1) && (n>=40 && n<=581) && (m>=124 &&
m<=148))
{
//FC
clrType=2;
}
if((button&1) && (n>=40 && n<=581) && (m>=162 &&
m<=186))
{
setDefaultBG();
setDefaultFontClr();
z=0;
}
if(clrType==1||clrType==2)
{
cleardevice();
paintButtons(20);
while(zz){
getmousepos(&button,&n,&m);
gotoxy(1,1);
if(button&1){
if(m<441&&m>330)
{
d=n/100;
num_button=d+12;
}
if(m<331&&m>220)
{
d=n/100;
num_button=d+8;
}
if(m<221&&m>110)
{
d=n/100;
num_button=d+4;
}
if(m<111&&m>10)
{
d=n/100;
num_button=d;
}
//cout<<"clrType"<<clrType;
paintButtons(num_button);
if(clrType==1)
{
setBGColor(num_button-1);
}
if(clrType==2)
{
setFontcolor(num_button-1);
}
}
}
}
/*void main(){
pickColor();
} */
MAIN.CPP
#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
#include<graphics.h>
#include<fstream.h>
#include<stdlib.h>
#include<LAYOUT.CPP>
#include<SETUP.CPP>
int z;
int bgclr;
int fntclr;
class MAIN:LAYOUT{
MPOINT mptr;
public:
int showText(char * file,char *header,int type);
public:
void showMenu();
public:
void strucAni();
void fusionAni();
void fusionEq();
void fissionAni();
void decay();
public:
void init(){
bgclr=6;
fntclr=15;
start_it();
showMenu();
}
};
int MAIN::showText(char *file,char *header,int type){
{
char ch[100];
ifstream jk;
int button,m,n;
cleardevice();
setcolor(14);
settextstyle(5,0,3);
outtextxy(320,5,header);
jk.open(file,ios::in);
settextstyle(6,0,1);
counter=1;
next:
settextstyle(6,0,1);
//button_3d(15,425,65,450,0,"MORE",1);
//button_3d(530,425,580,450,0,"EXIT",1);
//button_3d(222,456,385,470,0,"MAIN MENU",1);
showButtons();
setcolor(fntclr);
int axis=90;
for(int count=1;count<20;count++)
{
if(jk.getline(ch,80) )
outtextxy(325,axis,ch);
axis+=15;
}
counter++;
cout<<"clicks "<<counter<<endl;
if(type==1)
{
if(counter==16)
{
strucAni();
}
if(counter>18)
{
counter=0;
showMenu();
}
}
if(type==5)
{
if(counter==50)
{
fusionAni();
}
if(counter==51)
{
fusionEq();
}
if(counter==60)
{
showMenu();
}
}
if(type==4)
{
if(counter==2){
fissionAni();
}
if(counter==3)
{
showMenu();
}
}
setcolor(15);
z=1;
while(z)
{
mptr.getmousepos(&button,&n,&m);
gotoxy(1,1);
cout<<"n ="<<n<<" m = "<<m<<" ";
if((button&1) && (n>=15 && n<=65) && (m>=425 &&
m<=450))
{cleardevice();
goto next; }
while(z)
{
mptr.getmousepos(&button,&n,&m);
gotoxy(1,1);
// button_3d(530,425,580,450,0,"EXIT",1);
//showText("","",3);
}
showText("fusion.txt","Nuclear Fusion",5);
}
// (40,314,581,338,
if((button&1) && (n>=40 && n<=581) && (m>=314 &&
m<=338))
{
//plants();
showText("plants.txt","Nuclear Plants",6);
}
// button_3d(40,276,581,300,0,"CHAPTER 6: GREAT
DISCOVERIES ",5) ;
if((button&1) && (n>=40 && n<=581) && (m>=276 &&
m<=300))
{
// discovery();
showText("disco.txt","Great Discoveries",7);
}
settextstyle(3,0,3);
button_3d(530,425,580,450,0,"EXIT",1);
button_3d(222,456,385,475,0,"MAIN MENU",1);
int fw=1;
while(fw)
{
mptr.getmousepos(&button,&n,&m);
gotoxy(1,1);
//cout<<"n ="<<n<<" m = "<<m<<" ";
if((button&1) && (n>=530 && n<=580) && (m>=425 &&
m<=450))
{ end_it();
exit(0);
button=0;
z=0;
}
}
// (40,200,581,224,0,"SECTION 8D: NUCLEAR RESEARCH
",3)
if((button&1) && (n>=40 && n<=581) && (m>=200 &&
m<=224))
{
//research();
showText("research.txt","Nuclear Research",10);
}
if((button&1) && (n>=40 && n<=581) && (m>=124 &&
m<=148))
{
//energy();
showText("energy.txt","Nuclear Energy",11);
}
cleardevice();
//bgclr=clr;
showMenu();
}
}
}
void MAIN::strucAni(){
settextstyle(5,0,3);
//outtextxy(6,434,"structure of an atom");
settextstyle(15,0,1);
delay(500);circle(318,239,50);
delay(500);outtextxy(320,215,"NUCLEUS");
delay(500);outtextxy(315,241,"protons");
delay(500);outtextxy(315,260,"neutrons");
delay(1000);
circle(318,239,120);
delay(500);circle(318,239,150);
delay(500);circle(318,239,180);
delay(500);circle(318,239,210);
delay(200);outtextxy(443,235,"K");
delay(200);outtextxy(473,235,"L");
delay(200);outtextxy(503,235,"M");
delay(200);outtextxy(533,235,"N");
delay(1000);circle(318,119,5);
delay(100);circle(318,89,5);
delay(100);circle(318,59,5);
delay(100);circle(318,29,5);
delay(100);circle(318,358,5);
delay(100);circle(318,388,5);
delay(100);circle(318,418,5);
delay(100);circle(318,448,5);
delay(100);circle(168,235,5);
delay(100);circle(138,235,5);
delay(100);circle(108,235,5);
delay(100);circle(214,133,5);
delay(100);circle(191,111,5);
delay(100);circle(174,87,5);
delay(100);circle(208,338,5);
delay(100);circle(189,363,5);
delay(100);circle(168,384,5);
delay(100);circle(425,133,5);
delay(100);circle(449,113,5);
delay(100); circle(470,95,5);
delay(100); circle(428,342,5);
delay(100); circle(446,365,5);
delay(100); circle(466,389,5);
delay(1000);line(169,86,15,88);
delay(200);line(105,231,15,88);
delay(200);outtextxy(50,76,"electrons");
delay(1000);line(483,166,557,76);
delay(200);line(439,151,557,76);
delay(200);outtextxy(558,62,"orbits");
void MAIN::decay()
{ cleardevice();
circle(290,235,10);
circle(290,255,10);
circle(290,215,10);
circle(290,275,10);
circle(310,215,10);
circle(310,235,10);
circle(310,255,10);
circle(310,275,10);
circle(270,215,10);
circle(270,235,10);
circle(270,255,10);
circle(270,275,10);
circle(330,215,10);
circle(330,235,10);
circle(330,255,10);
circle(330,275,10);
circle(299,244,53);
line(337,208,423,132);
line(261,207,171,127) ;
line(263,283,165,362) ;
line(337,282,432,359) ;
settextstyle(5,0,3);
setcolor(7);
outtextxy(423,115,"alpha emission");
outtextxy(176,98,"beta emission");
outtextxy(165,362,"positron emission");
outtextxy(432,359,"gamma emission");
setcolor(5);
settextstyle(8,0,2);
outtextxy(300,29,"TYPES OF EMISSIONS");
setcolor(15);
settextstyle(6,0,1);
button_3d(15,425,65,450,0,"MORE",1);
button_3d(530,425,580,450,0,"EXIT",1);
button_3d(222,456,385,470,0,"MAIN MENU",1);
}
void MAIN::fusionAni(){
cleardevice();
settextstyle(1,0,1) ;
int j=467;
for(int i=123;i<=295;i++)
{setcolor(0);
circle(i-1,123,20);
circle(j+1,123,20);
setcolor(15);
circle(i,123,20);
circle(j,123,20);
j--;
delay(10);}
setcolor(0);
circle(295,123,20);
setcolor(15);
circle(295,123,40);
settextstyle(5,0,3);
delay(500); outtextxy(298,202,"NUCLEUR FUSION");
delay(500); outtextxy(235,283,"Here 2 hydrogen nucleus
collide to form a helium nucleus");
outtextxy(235,330,"Huge amount of energy is also
produced");
outtextxy(235,377,"These types of reactions take place in
stars");
settextstyle(6,0,1);
button_3d(15,425,65,450,0,"MORE",1);
button_3d(530,425,580,450,0,"EXIT",1);
button_3d(222,456,385,470,0,"MAIN MENU",1);
}
void MAIN::fusionEq(){
settextstyle(3,0,2);settextjustify(0,0);
outtextxy(100,130," 1H1 + 1H1 --> 2H1 + e+ + v +
0.42MeV");
outtextxy(100,150," 2H1 + 2H1 --> 3He2 + n + 3.27MeV");
outtextxy(100,170," 2H1 + 2H1 --> 3H1 + 1H1 + 4.03MeV");
getch();
}
void MAIN::fissionAni(){
cleardevice();
int t=108, u=1;
circle(300,195,60);
for(; u<=151&&t<=259;t++,u++)
{
setcolor(15);
circle(t,u,5);
setcolor(0);
circle(t-1,u-1,5);
delay(25);
}
setcolor(0);
circle(300,195,60);
setcolor(0);
circle(t-1,u-1,5);
setcolor(15);
delay(50);
circle(238,195,20);
circle(359,195,20);
int j=238;
for(int i=359;i<=450;i++)
{setcolor(0);
circle(i-1,195,20);
circle(j+1,195,20);
setcolor(15);
circle(i,195,20);
circle(j,195,20);
j--;
delay(10);}
settextstyle(5,0,3);
outtextxy(306,247,"NUCLEAR FISSION");
outtextxy(306,320,"A neutron strickes an uranium nucleus and
fission takes place");
outtextxy(306,345,"Then uranium nucleus converts into Xenon
and Strontium");
outtextxy(306,370,"Here also huge amount of energy is
produced");
settextstyle(6,0,1);
button_3d(15,425,65,450,0,"MORE",1);
button_3d(530,425,580,450,0,"EXIT",1);
button_3d(222,456,385,470,0,"MAIN MENU",1);
}
void main()
{
MAIN m;
m.init();
}
$ WELCOME ANIMATIONS $
$ WELCOME SCREEN $
$ MAIN MENU $
$ DATA ON STRUTURE OF ATOM $
$ SCHEMATIC DIAGRAM SHOWING $
STRUCTURE OF DIAGRAM
$ DATA ON “ THE NUCLEUS” $
$ ANIMATION SHOWING NUCLEAR FISSION $
$ DATA AND ANIMATION ON “ NUCLEAR FUSION” $
(Note the tabs on the output screens having options for getting
more data, returning to main menu and for exit.)
$ MORE DATA ON NUCLEAR ENERGY AND FORCES $
$ OUTPUT SCREEN DISPLAYING DATA ON $
“NUCLEAR FUEL CYCLE”
AND
“RADIOACTIVE HAZARDS”
OUTPUT SCREEN DISPLAYING DATA ON
“NUCLEAR RESEARCH”
NOTE:- The user could access these options buy just clicking on
the respective tab. Different color tabs are displayed on the
screen (showed on the next page). After alterations are made,
click on the
“ BACK” tab to return to the main menu.
$ COLOR TABS $
II. INTRODUCTION
ITS HISTORY
WORDS ABOUT C++
FEATURES OF C++
PREPROCESSOR DIRECTIVES
COMPILING AND LINKING
DATA ABSTRACTION
ENCAPSULATION
POLYMORPHISM
INHERITANCE
IX. BIBLIOGRAPHY
BIBLIOGRAPHY
GOOGLE SEARCH
YAHOO SEARCH
ETC