Twitter: Iimt Engineering Colege
Twitter: Iimt Engineering Colege
Twitter: Iimt Engineering Colege
SUBMITTED TO:
Mr. Achilesh Tyagi.
Department: BCA
HOD: Mr. Neeraj Sharma
INDEX
Sr.N Topic Page No.
o.
1 Acknowledgement 3
2 Certificate 4
3 Introduction to 5
TWITTER
4 Scope and 6
Objective of the
Project
5 System 8
Development life
Cycle
6 Software and 10
hardware
requirements
7 Language Used(C+ 11
+)
8 Dataflow Diagram 13
9 Source Code 14
2
10 Snapshots 73
11 Bibliography 78
ACKNOWLEDGEMENT
I
Gratefully acknowledge the valuable
contributions and suggestions of my dear
friends, class mates and a helping hand
from our most respectable subject
teacher Mr. Achilesh Tyagi who was
always with me to help me in any
manner he can. I hope that I would get
the same coordination from my teachers
and friends in future.
Checked by:
(Initials)
2
This is certified to be the
bonafide work of the student in
the Project during the academic
year 2009-2010.
………………………
(Teachers Signature)
Now the organizations have system oriented approach rather than user
oriented. User having basic knowledge of computer can maintain the
approach. Now it is very easy to maintain all the posts and followers.
2
This project provides real time solution to all the queries. Posts
of tweets and posts of the tweets of your follower, all of them can be viewed
, can be generated at any time or when suitable.
The project provides accuracy to the tracking of new posts and to all
the inputs. Some parts of information like date and time of tweet are
automatically added by the program. It saves the time of user
and now large volume of tweets for communication handled smoothly
and easily.
• User Friendly
2
SYSTEM DEVELOPMENT CYCLE
(SDLC)
2
MAINTENANCE :- Maintenance of the system involves activities like
fixing problems that may arise while running the system and
evaluating and incorporating change requests.
HARDWARE REQUIREMENTS:
Memory: 16 MB RAM
2
Monitor: 15 Inch color monitor
SOFTWARE REQUIREMENTS:
Windows 2000
LANGUAGE USED
C++:- C++ programming language was developed
at AT&T Bell laboratories in the early 1980s by Bjarne
Stroustrup. This language was called as “C with classes”
originally. The name ‘C++’ was coined by Rick Mascitti
where “++” is the C increment operator.
The major reason behind the success and popularity
of the C++ is that it supports the Object Oriented
Programming (OOP), the latest in the software
development and the most near to the real world. One
can easily judge the importance of C++ as given in the
following lines:
2
“Object Oriented Technology is regarded as
the ultimate paradigm for the modeling information, be hat
data or logic. The C++ has by now shown to fulfill this goal.”
Features of C++:- The OOP approach is based on
certain concepts that help it attain its goal of
overcoming the drawbacks or shortcomings of
conventional programming approaches. These general
concepts of OOP are given below:
1. Data Abstraction
2. Data Encapsulation
3. Inheritance
4. Polymorphism
2
Program Source Code:
#include<RAJ.H>
tfollow thefollows;
ifstream followf;
int counter=0;
followf.open("tfollow.sam",ios::in|ios::binary);
while(!followf.eof())
followf.read((char*)&thefollows,sizeof(thefollows));
if(strcmp(thefollows.user1,logedinuser)==0)
strcpy(followlist[counter],thefollows.user2);
counter++;
if(counter>(loggedinfollows-1))
followf.close();
return 1;
2
}
followf.close();
return 0;
/*******************************/
int whathedid()
tweets thetweet;
tuser theuser;
switch(mytweet[0])
case '1':
if(tweetfavail==0||hastweets==0)
2
gotoxy(1,MAXY);
textbackground(2);
clrscr();
gotoxy(2,8);
return 1;
viewtweets();
return 1;
case '2':
follow();
return 2;
case '3':
pifollow();
return 3;
2
}
case '4':
textbackground(4);
clrscr();
gotoxy(1,MAXY);
textbackground(2);
while(!kbhit())
\r");
delay(200);
2
cprintf("|| [ | ] Logged Out Successfully | Press any key to go
back to Home
\r");
delay(200);
\r");
delay(200);
\r");
delay(200);
getch();
return 4;
case '5':
deleteacc();
return 5;
2
case '6':
about();
return 6;
default:
if(!strlen(mytweet)==0)
getdate(&thetweet.tdate);
gettime(&thetweet.ttime);
strcpy(thetweet.tuser,logedinuser);
strcpy(thetweet.tweet,mytweet);
tweetf.open("tweets.sam",ios::out|ios::app|ios::ate|ios::binary);
tweetf.write((char*)&thetweet,sizeof(thetweet));
tweetf.close();
textbackground(2);
clrscr();
userf.open("userf.sam",ios::in|ios::out|ios::binary);
2
userf.seekg(0);
while(!userf.eof())
pos=userf.tellg();
userf.read((char*)&theuser,sizeof(theuser));
if((strcmp(theuser.tusername,logedinuser)==0)&&(strcmp(the
user.tpassword,password)==0))
theuser.hastweet=1;
userf.seekg(pos);
userf.write((char*)&theuser,sizeof(theuser));
userf.close();
break;
userf.close();
gotoxy(1,MAXY);
2
cout<<" || *** Tweet Saved Successfully ***
||";
gotoxy(2,8);
while(!kbhit()){}
gotoxy(2,8);
return 7;
else
_setcursortype(_NOCURSOR);
gotoxy(1,MAXY);
while(!kbhit()){}
gotoxy(2,8);
_setcursortype(_NORMALCURSOR);
return 7;
2
}
/*******************************/
int viewtweets() //Return value may not be used, its just to escape
tweets thetweet;
ifstream tweetf;
ofstream temptweetf;
int counter,keypress;
int spaceneeded;
int haveroom;
long pos=0;
textbackground(2);
puttext(1,1,80,MAXY,fscreenbuf);
gotoxy(1,MAXY);
window(2,12,79,MAXY-2);
textbackground(2);
2
clrscr();
tweetf.open("tweets.sam",ios::in|ios::binary);
temptweetf.open("~temptf.sam",ios::out|ios::binary);
while(!tweetf.eof())
tweetf.read((char*)&thetweet,sizeof(thetweet));
for(counter=0;counter<=loggedinfollows;counter++)
if((strcmp(thetweet.tuser,followlist[counter])==0)||
(strcmp(thetweet.tuser,logedinuser)==0))
temptweetf.write((char*)&thetweet,sizeof(thetweet));
break;
tweetf.close();
temptweetf.close();
2
counter=0;
tweetf.open("~temptf.sam",ios::in|ios::binary|ios::nocreate);
while(!tweetf.eof())
tweetf.seekg(pos);
tweetf.read((char*)&thetweet,sizeof(thetweet));
if (strlen(thetweet.tweet)<78) {spaceneeded=2;}
if (strlen(thetweet.tweet)<154) {spaceneeded=3;}
if (strlen(thetweet.tweet)<234) {spaceneeded=4;}
if (wherey()<((MAXY-11)-spaceneeded)) {haveroom=1;}
else {haveroom=0;}
if (haveroom==0)
while(1)
keypress=getch();
if(keypress==ESC)
2
window(1,1,80,MAXY);
tweetf.close();
gotoxy(2,8);
return (0);
if(keypress==UP)
clrscr();
pos-=(sizeof(thetweet)*counter);
counter=0;
break;
if(keypress==DN)
2
if(!tweetf.eof())
pos+=sizeof(thetweet);
counter++;
tweetf.read((char*)&thetweet,sizeof(thetweet));
if(!tweetf.eof()){break;}
else
pos+=sizeof(thetweet);
counter++;
2
}
while(1)
while(!kbhit()){}
keypress=getch();
if(keypress==ESC)
tweetf.close();
remove("~temptf.sam");
gotoxy(2,8);
return (0);
/*******************************/
2
/*Function to view users and follow them*/
void follow()
int keypress;
tuser theuser;
tfollow thefollow;
fstream userf;
ofstream followf;
long pos=0;
int found=0,success=0;
gotoxy(1,MAXY);
textbackground(2);
window(2,8,79,10);
window(2,12,79,MAXY-2);
userf.open("userf.sam",ios::in|ios::out|ios::binary);
int x=5,y=2,ct=0;
userf.seekg(pos);
2
userf.read((char*)&theuser,sizeof(theuser));
if(ct<5)
gotoxy(x,y);
x+=15; ct++;
else
x=5;
gotoxy(x,++y);
ct=0;
cprintf("%s",theuser.tusername);
userf.read((char*)&theuser,sizeof(theuser));
userf.close();
gotoxy(2,8);
2
while(1)
while(!kbhit()){}
keypress=getche();
if(keypress==ESC)
break;
else
textbackground(2);
clrscr();
gotoxy(2,8);
cout<<"Enter Username:";
userf.open("userf.sam",ios::in|ios::out|ios::binary);
userf.read((char*)&theuser,sizeof(theuser));
while(!userf.eof())
2
{
exist or not
found=1;
break;
else
found=0;
userf.read((char*)&theuser,sizeof(theuser));
if(found==1)
userf.seekg(0);
userf.read((char*)&theuser,sizeof(theuser));
pos=userf.tellg();
while(!userf.eof())
2
if(strcmp(logedinuser,theuser.tusername)==0) //then we find
logedin user
theuser.nfollows++;
userf.seekg(pos-sizeof(theuser));
userf.write((char*)&theuser,sizeof(theuser));
userf.close();
followf.open("tfollow.sam",ios::out|ios::app|ios::binary|
ios::ate);
strcpy(thefollow.user1,logedinuser);
strcpy(thefollow.user2,mysizetext);
followf.write((char*)&thefollow,sizeof(thefollow));
followf.close();
success=1;
break;
else
2
success=0;
userf.read((char*)&theuser,sizeof(theuser));
pos=userf.tellg();
else
userf.close();
gotoxy(1,MAXY);
gotoxy(2,8); //We dont want the user to see cursor in status bar
while he sees the status
while(!kbhit()) {}
gotoxy(1,MAXY);
gotoxy(2,8);
if(success==1)
2
userf.close();
gotoxy(1,MAXY);
cout<<" \r";
gotoxy(78,MAXY);
cout<<"||";
gotoxy(2,8); //We dont want the user to see cursor in status bar
while he sees the status
while(!kbhit()) {}
gotoxy(1,MAXY);
gotoxy(2,8);
puttext(1,1,80,MAXY,fscreenbuf);
gotoxy(2,8);
/*******************************/
2
/*Function to show list of users he follow*/
void pifollow()
int j,ch,x=5,y=2,ct=0;
populatelist();
gotoxy(1,MAXY);
if(i==0)
puttext(1,1,80,MAXY,fscreenbuf);
gotoxy(2,8);
while(!kbhit()){}
else
_setcursortype(_NOCURSOR);
2
cout<<" || Above is the List of People you are following | Press
ESC to exit ||";
window(2,12,79,MAXY-2);
textbackground(2);
clrscr();
for(j=0;j<i;j++)
if(ct<5)
gotoxy(x,y);
x+=15; ct++;
else
x=5;
gotoxy(x,++y);
ct=0;
cprintf("%s",followlist[j]);
while(1)
2
while(!kbhit()){}
ch=getch();
if(ch==ESC)
break;
window(1,1,80,MAXY);
puttext(1,1,80,MAXY,fscreenbuf);
_setcursortype(_NORMALCURSOR);
gotoxy(2,8);
/*******************************/
void main()
getch();
2
RAJ.H
#include<io.h>
#include<conio.h>
#include<dos.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
#include<fcntl.h>
#include<process.h>
/*Created on 1/21/2010
2
6 Brown yes yes
14 Yellow no yes
15 White no yes
Files Used:
userf.sam
tfollow.sam
tweets.sam
Functions: */
int homedisplay();
void getpassword();
void loginbox();
2
void initialize();
void newaccbox();
int populatelist();
void startsoft();
void loggedinscreen();
int whathedid();
int viewtweets();
void follow();
void pifollow();
void deleteacc();
void about();
/********************************/
int userfavail=0;
int tweetfavail=0;
int followfavail=0;
int ux;
int uy;
int MAXY;
int loggedinfollows;
2
int hastweets;
char tbuf[960];
char fscreenbuf[8000];
char password[12];
char mysizetext[12];
char mytweet[234];
char logedinuser[12];
char followlist[100][12];
/*******************************/
/*Project classes*/
class tuser
public:
char tusername[12];
char tpassword[12];
int nfollows;
int hastweet;
};
2
class tweets
public:
char tuser[12];
char tweet[234];
};
class tfollow
public:
char user1[12];
char user2[12];
};
/*******************************/
2
/*Function to color background*/
//Here i just tricked clrscr() to paint the screen with custom color
clrscr();
textbackground(color1);
textcolor(color2);
clrscr();
/*******************************/
int homedisplay()
int a,i,y1,y2,y3;
_setcursortype(_NOCURSOR);
2
gettextinfo(&ti); //sure this animation works
y1=MAX_Y/2;
i=(MAX_Y/2)-2;
y2=y1+1;
y3=y1+2;
while(i>0)
textcolor(4);
textbackground(0);
clrscr();
textbackground(3);
gotoxy(30,y1--);
cprintf(" ");
gotoxy(30,y2);
cprintf(" ");
textbackground(0);
gotoxy(38,y2--);
a=((i%2)*4);
textcolor(a);
cprintf("TWITTER");
2
textbackground(3);
cprintf(" ");
gotoxy(30,y3--);
cprintf(" ");
i--;
// delay(500);
// else
// delay(300);
gotoxy(29,2);
cprintf(" ");
gotoxy(29,6);
cprintf(" ");
textbackground(5);
y1=(MAX_Y/2)+5;
gotoxy(29,y1++);
cprintf(" ");
gotoxy(29,y1);
cprintf(" ");
2
cout<<" Enter yor Choice";
gotoxy(53,y1++);
cprintf(" ");
if(userfavail==1)
gotoxy(29,y1);
cprintf(" ");
cout<<" 1: Login";
gotoxy(53,y1++);
cprintf(" ");
else
gotoxy(29,y1);
cprintf(" ");
gotoxy(53,y1++);
cprintf(" ");
gotoxy(29,y1);
2
cprintf(" ");
gotoxy(53,y1++);
cprintf(" ");
gotoxy(29,y1);
cprintf(" ");
cout<<" 3: Exit";
gotoxy(53,y1++);
cprintf(" ");
_setcursortype(_NORMALCURSOR);
while(1)
textbackground(5);
gotoxy(29,y1);
cprintf(" ");
gotoxy(42,y1);
cprintf(" ");
textbackground(0);
gotoxy(41,y1);
i=(int)getchar();
2
break;
break;
return (i-48);
/*******************************/
int ix=x1;
int iy=y1;
if(!(x2<x1||y2<y1))
textbackground(color1);
for(;y1<=y2;y1++)
for(;x1<=x2;x1++)
2
if(y1==iy||x1==ix||y1==y2||x1==x2)
gotoxy(x1,y1);
cprintf(" ");
x1=ix;
gotoxy(ix+1,iy+1);
ux=ix+1; uy=iy+1;
/*******************************/
void getpassword()
int a=0;
while(1)
password[a]=getch();
2
if(password[a]==8) //Check if Backspace was pressed
if(!(a==0))
a--;
cout<<"\b \b";
continue;
else
password[a]='\0';
break;
cout<<"*";
a++;
if(a>11)
2
a--;
cout<<"\b \b";
/*******************************/
void loginbox()
createbox(29,(MAX_Y/2)+5,53,(MAX_Y/2)+9);
cout<<"Username: ";
createbox(29,(MAX_Y/2)+7,53,(MAX_Y/2)+7);
gotoxy(30,(MAX_Y/2)+8);
cout<<"Password: ";
gotoxy(40,(MAX_Y/2)+6);
ux=40; uy=(MAX_Y/2)+6;
2
}
/*******************************/
void newaccbox()
mycolorscreen(0,15);
createbox(25,(MAXY/2)+4,56,(MAXY/2)+12);
createbox(25,(MAXY/2)+6,56,(MAXY/2)+8);
cout<<"Username :";
gotoxy(26,(MAXY/2)+9);
cout<<"Password :";
createbox(25,(MAXY/2)+10,56,(MAXY/2)+12);
cout<<"Confirm Password:";
gotoxy(43,(MAXY/2)+7);
ux=43; uy=(MAXY/2)+7;
/*******************************/
2
/*Function to get custom sized text*/
int a=0,thex;
if(size<13)
while(1)
mysizetext[a]=getch();
if(!(a==0))
a--;
cout<<"\b \b";
continue;
else
2
{
mysizetext[a]='\0';
break;
cout<<mysizetext[a];
a++;
if(a>size)
a--;
cout<<"\b \b";
else
while(1)
2
mytweet[a]=getch();
if(!(a==0))
a--;
if(!(thex<3))
cout<<"\b \b";
else
gotoxy(79,--uy);
cout<<" \b";
continue;
else
2
mytweet[a]='\0';
break;
if(thex<=79)
cout<<mytweet[a];
else
gotoxy(2,++uy);
cout<<mytweet[a];
a++;
if(a>size-1)
a--;
cout<<"\b \b";
/*******************************/
2
/*Function to initialize variables and check files*/
void initialize()
int handle;
handle=creatnew("userf.sam",0);
if(handle==-1)
handle=open("userf.sam",O_CREAT);
close(handle); remove("userf.sam");
creatnew("userf.sam",0); close(handle);
userfavail=0;
else
userfavail=1;
else
close(handle);
2
userfavail=0;
handle=creatnew("tfollow.sam",0);
if(handle==-1)
handle=open("tfollow.sam",O_CREAT);
if((filelength(handle))<(sizeof(tfollow)))
close(handle); remove("tfollow.sam");
creatnew("tfollow.sam",0); close(handle);
followfavail=0;
else
followfavail=1;
else
close(handle);
followfavail=0;
2
handle=creatnew("tweets.sam",0);
if(handle==-1)
handle=open("tweets.sam",O_CREAT);
if((filelength(handle))<(sizeof(tweets)))
close(handle); remove("tweets.sam");
creatnew("tweets.sam",0); close(handle);
tweetfavail=0;
else
tweetfavail=1;
else
close(handle);
tweetfavail=0;
/*******************************/
2
/*Function to start this software*/
void startsoft()
int a;
MAXY=MAX_Y;
a=homedisplay();
switch (a)
case 1:
ifstream userf;
tuser theuser;
int found=0;
while(1)
loginbox();
2
getmysizetext(12);
gotoxy(ux,uy+2);
getpassword();
userf.open("userf.sam",ios::in|ios::binary);
while(!userf.eof())
userf.read((char*)&theuser,sizeof(theuser));
if((strcmp(theuser.tusername,mysizetext)==0)&&(strcmp(theu
ser.tpassword,password)==0))
found=1;
userf.close();
break;
userf.close();
if(found==1)
2
break;
else
textcolor(15);
textbackground(0);
clrscr();
gotoxy(27,(MAX_Y/2)+4);
continue;
if(choice==7||choice==1||choice==2||choice==3||choice==6)
if(choice==4||choice==5)
break;
2
}
case 2:
char pass1[12],pass2[12];
newaccbox();
while (1)
gotoxy(ux,uy);
getmysizetext(12);
gotoxy(ux,uy+=2);
getpassword();
strcpy(pass1,password);
gotoxy(ux,uy+=2);
getpassword();
strcpy(pass2,password);
if((strcmp(pass1,pass2))!=0)
textcolor(15); textbackground(0);
clrscr();
newaccbox();
gotoxy(26,(MAX_Y/2+5));
2
cout<<"Sorry Passwords do not match ";
else
ofstream ouserf;
tuser newuser;
strcpy(newuser.tusername,mysizetext);
strcpy(newuser.tpassword,password);
newuser.nfollows=0;
newuser.hastweet=0;
ouserf.open("userf.sam",ios::out|ios::app|ios::binary);
ouserf.write((char*)&newuser,sizeof(newuser));
ouserf.close();
_setcursortype(_NOCURSOR);
gotoxy(26,(MAX_Y/2)+5);
delay(2000);
_setcursortype(_NORMALCURSOR);
startsoft();
break;
2
}
break;
case 3:
exit (0);
/*******************************/
void loggedinscreen()
mycolorscreen(2,15);
createbox(1,7,80,(MAXY-1),4);
createbox(2,11,79,11,4);
gotoxy(2,MAXY);
gotoxy(5,(MAXY/2)+3);
if(MAXY<43)
2
{
gotoxy(ux,uy+=1);
gotoxy(ux,uy+=1);
gotoxy(ux,uy+=1);
cout<<"4: Logout";
gotoxy(ux,uy+=1);
gotoxy(ux,uy+=1);
else
gotoxy(ux,uy-=6);
gotoxy(ux,uy+=3);
gotoxy(ux,uy+=3);
2
gotoxy(ux,uy+=3);
cout<<"4: Logout";
gotoxy(ux,uy+=3);
gotoxy(ux,uy+=3);
gotoxy(2,8);
/*******************************/
void deleteacc()
ifstream userf,ffollow,ftweets;
ofstream utemp,ftemp,ttemp;
tuser theuser;
tweets thetweet;
2
tfollow thefollow;
textbackground(2);
userf.open("userf.sam",ios::in|ios::binary);
utemp.open("utemp.sam",ios::out|ios::binary);
gotoxy(1,MAXY);
delay(400);
while(!userf.eof())
userf.read((char*)&theuser,sizeof(theuser));
if(!(strcmp(theuser.tusername,logedinuser)==0)&&(!
strcmp(theuser.tpassword,password)==0))
userf.close();
utemp.close();
2
cprintf("|| [ | ] Account being deleted
\r");
delay(400);
ffollow.open("tfollow.sam",ios::in|ios::binary);
ftemp.open("ftemp.sam",ios::out|ios::binary);
while(!ffollow.eof())
ffollow.read((char*)&thefollow,sizeof(thefollow));
if(!(strcmp(thefollow.user1,logedinuser)==0))
ffollow.close();
ftemp.close();
delay(400);
2
delay(400);
delay(400);
ftweets.open("tweets.sam",ios::in|ios::binary);
ttemp.open("ttemp.sam",ios::out|ios::binary);
while(!ftweets.eof())
ftweets.read((char*)&thetweet,sizeof(thetweet));
if(!strcmp(thetweet.tuser,logedinuser)==0)
ttemp.write((char*)&thetweet,sizeof(thetweet));
ftweets.close();
ttemp.close();
delay(400);
remove("userf.sam");
2
remove("tfollow.sam");
remove("tweets.sam");
rename("utemp.sam","userf.sam");
rename("ftemp.sam","tfollow.sam");
rename("ttemp.sam","tweets.sam");
textbackground(4);
clrscr();
gotoxy(1,MAXY);
textbackground(2);
while(!kbhit())
delay(200);
2
cprintf("|| [ | ] Account Deleted Successfully | Press any key to
go back to Home \r");
delay(200);
delay(200);
delay(200);
getch();
/*******************************/
/*************END OF CODE************/
2
RUNTIME SCREEN SHOTS
2
2
2
2
2
BIBLIOGRAPHY