1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
//-----------------------------------------------------------------------------
class aircraft
{
public:
int long tail_no;
int flying_hours;
int no_of_seats;
char aircraft_name[20],base[20],pilot_name[20],copilot_name[20],pilot_rank[10],copilot_rank[10],armaments[10][20];
int qty[10], temp_qty;
aircraft();
void enter_aircraftdet();
void get_aircraftdet();
};
aircraft::aircraft()
{
strcpy(aircraft_name,'\0');
no_of_seats=2;
flying_hours=0;
strcpy(base,'\0');
strcpy(pilot_name,'\0');
strcpy(pilot_rank,'\0');
strcpy(copilot_name,'\0');
strcpy(copilot_rank,'\0');
strcpy(armaments[10],'\0');
}
void aircraft::enter_aircraftdet()
{
int i=0;
cout<<"\n Enter Aircraft Name : "; gets(aircraft_name);
cout<<"\n Enter Tail No. : "; cin>>tail_no;
cout<<"\n Enter The Base Name : "; gets(base);
cout<<"\n Enter Flying Hours : "; cin>>flying_hours;
cout<<"\n Enter Number Of Seats (1 or 2) : "; cin>>no_of_seats;
cout<<"\n Enter Pilot's Name (Name or Type \"NULL\" If Not Assigned): "; cin>>pilot_name;
cout<<"\n Enter Pilot's Rank (Rank or Type \"NULL\" If Pilot Not Assigned): "; cin>>pilot_rank;
cout<<"\n Enter Co-Pilot's Name (Name or Type \"NULL\" If Not Assigned): "; cin>>copilot_name;
cout<<"\n Enter Co-Pilot's Rank (Rank or Type \"NULL\" If Co-Pilot Not Assigned): "; cin>>copilot_rank;
for(int arm=0;arm<10;arm+=temp_qty)
{
cout<<"\n Enter The Armaments (Maximum 10): "; cin>>armaments[arm];
cout<<"\n Enter Quantity Of Entered Weapon "; cin>>temp_qty;
qty[i]=temp_qty;
i++;
}
}
void aircraft::get_aircraftdet()
{
int i=0;
cout<<"\n Aircraft Name : "; puts(aircraft_name);
cout<<"\n Tail No. : "; cout<<tail_no;
cout<<"\n Base Name : "; gets(base);
cout<<"\n Flying Hours : "; cout<<flying_hours;
cout<<"\n Pilot's Name ( NULL If Not Assigned): "; cout<<pilot_name;
cout<<"\n Pilot's Rank ( NULL If Pilot Not Assigned): "; cout<<pilot_rank;
cout<<"\n Co-Pilot's Name ( NULL If Not Assigned): "; cout<<copilot_name;
cout<<"\n Co-Pilot's Rank ( NULL If Co-Pilot Not Assigned): "; cout<<copilot_rank;
for(int arm=0;arm<10;arm+=qty[i])
{
cout<<"\n WEAPON \t\t\t\t QUANTITY\n ";
cout<<armaments[arm]<<" \t\t\t\t "<<qty[i];
i++;
}
}
//-----------------------------------------------------------------------------
class pilot
{
public:
char pilots_name[20], pilots_rank[20], pilots_squadron[20], base[20];
int flying_hours, aircraft_assigned;
double salary;
void enter_pilotdet();
void get_pilotdet();
};
void pilot::enter_pilotdet()
{
cout<<"\n Enter Pilot Name : "; gets(pilots_name);
cout<<"\n Enter Rank : "; gets(pilots_rank);
cout<<"\n Enter The Base Name : "; gets(base);
cout<<"\n Enter Flying Hours : "; cin>>flying_hours;
cout<<"\n Enter Assigned Aircraft's Tail No. (No. or Type 0 If Not Assigned): "; cin>>aircraft_assigned;
cout<<"\n Enter Salary : "; cin>>salary;
}
void pilot::get_pilotdet()
{
cout<<"\n Pilot Name : "; puts(pilots_name);
cout<<"\n Rank : "; puts(pilots_rank);
cout<<"\n The Base Name : "; puts(base);
cout<<"\n Flying Hours : "; cout<<flying_hours;
cout<<"\n Assigned Aircraft's Tail No. (0 If Not Assigned): "; cout<<aircraft_assigned;
cout<<"\n Salary : "; cout<<salary;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void main()
{ int choice;
aircraft plane;
pilot officer;
again:
cout<<"\n\t\t\t*** WELCOME TO INDIAN AIR FORCE PAGE ***";
cout<<"\n Please Enter Your Task";
cout<<"\n \t \a1). ADMINISTRATOR ";
cout<<"\n \t 2). ASSIGN PILOTS TO AIRCRAFTS";
cout<<"\n \t 3). ASSIGN AIRCRAFT TO A PILOT";
cout<<"\n \t 4). SEARCH FOR AN AIRCRAFT";
cout<<"\n \t 5). SEARCH FOR A PILOT";
cout<<"\n Enter Your Choice Here (1,2,3,4 or 5):";
cin>>choice; cout<<'\a';
clrscr;
//******************************************************************************
if(choice==1)
{
cout<<"\n Select Your Task";
cout<<"\n \t1). ADD NEW AIRCRAFT DETAILS";
cout<<"\n \t2). ADD NEW PILOT DETAILS";
cout<<"\n \t3). EDIT AIRCAFT DETAILS ";
cout<<"\n \t4). EDIT PILOT DETAILS";
cout<<"\n \t5). PROMOTE A PILOT";
if(choice==1)
{
plane.enter_aircraftdet();
ofstream aircraftfile;
aircraftfile.open("aircraftfile.dat",ios::ate||ios::binary);
aircraftfile.write((char*)&plane,sizeof(plane));
aircraftfile.close();
}
if(choice==2)
{
officer.enter_pilotdet();
ofstream pilotfile;
pilotfile.open("pilotfile.dat",ios::ate||ios::binary);
pilotfile.write((char*) &officer,sizeof(officer));
pilotfile.close();
}
if(choice==3)
{
int q=-1;
fstream aircraftfile;
aircraftfile.open("aircraftfile.dat",ios::app||ios::in||ios::binary);
int tno;
cout<<"\n Enter The Aircraft's Tail Number To Be Assigned Pilot(s) :"; cin>>tno;
while(!aircraftfile.eof())
{
aircraftfile.read((char*) &plane,sizeof(plane));
if(tno==plane.tail_no)
{
q++;
break;
}
};
if(q==-1)
{
cout<<"\n Sorry, Aircraft Not Found.";
}
else
{
cout<<"\n Aircraft Found!";
aircraftfile.write((char*) &plane,sizeof(plane));
}
aircraftfile.close();
}
if(choice==4)
{
}
if(choice==5)
{
}
if(choice>5)
{
}
}
|