Professional Documents
Culture Documents
4A21 - 56 - 63 - Armed Forces - CaseStudy02
4A21 - 56 - 63 - Armed Forces - CaseStudy02
4A21 - 56 - 63 - Armed Forces - CaseStudy02
KLE Society's
KLE Technological University
Submitted by
Faculty In-charge:
K M M Rajashekharaiah
1. Introduction
1.1 Overview of the Problem Statement
2. Design
3.2 Firing and reloading a gun: void fireGun(Gun *g), void reload(Gun *g)
4 Implementation
4.1 Results
1. Introduction
The Indian Armed Forces consists of different divisions: Indian Air Force, Indian Army and Indian
Navy. They consist of military personnel, artillery and military vehicles. Also, these divisions have
bases all over the country. Each base contains residential areas and military areas. The vehicles and
artillery are accommodated in the military areas. The military personnel stay in the residential areas.
Each of these forces conduct a recruitment drive after which the selected individuals are inducted in
that force. During wartime all these forces engage in combat by using the vehicles and artillery. Our
application will provide information about the military personnel, bases all over the country and the
forces which are engaged in war and other activities.
3. Simulate a War
In this feature the user can perform various war activities like firing a gun, throwing a
grenade, deploying a tank, submerging a submarine, deploying a warship and flying a fighter
jet. The guns can be fired in single and burst modes. The gun can be reloaded once all its
bullets have been fired. The grenade thrown gets deleted and cannot be used again.
2. Design
i. Class Diagram
ArmedForce
<<abstract>>
+bases[]:*Base
+mp[]:*MilitaryPersonnel
+ar[]:*Artillery
+v[]: * Vehicle
-mpno:int
+training(MilitaryPersonnel):void
+induction(Person):void
+virtual recruitment(Person):void=0
2. Navy
3. Army
4. AirForce
5. Vehicle
The above classes are used to create objects of vehicle type using factory
design pattern.
aircraftCapacity in WarShip tells us how many aircrafts it can carry.
These classes override the printVehicle() function of Vehicle class.
7. Artillery
8. Gun, Grenade
The above classes are used to create objects of artillery type using
factory design pattern.
Attribute magazineSize in Gun refers to number of bullets in the gun
which will keep getting decremented each time the gun is fired.
Reload function in Gun class can be used to reload bullets into the
gun.
Validation:
➔Verify magazineSize in Gun should be positive value. If it
becomes negative display appropriate error message.
9. Base
10. Person
11. MilitaryPersonnel
This class inherits from Person class and uses the Artillery,Vehicle and
ErrorException classes.
They reside in ResidentialArea.
Validation
In the fireGun() function we need to ensure that the number of bullets in the gun
should be greater than 0. If not an exception should be thrown.
12. ErrorException
There is a switch menu for different options like creating Person, Artillery, Vehicles and Bases.
Also options like recruiting MilitaryPersonnel and simulating a war are provided.
According to the user input we will create a Vehicle and an Artillery using factory design
pattern. Once they get created we ask user which military area they want to keep them in. After
creating a person user can enroll him for recruitment drive . Using Army, Navy and AirForce
objects any of the functions of ArmedForces can be called. Any exceptions are handled through
the instantiation of the object of ErrorException class.
Factory design pattern and singleton pattern are used for the above application.
• Factory method pattern(creational pattern):
The recruitment process involves giving person details, analyzing the details and
checking the eligibility criteria, giving the induction test and finally the induction of
that person in a particular force.
Then the person is asked for the force they want to join, and their eligibility is
checked:
Input:
1
Enter person details
Full Name: Ankit
Age: 18
Blood group: B+ve
Height: 1.88
Expected output:
Actual output:
Input:
1
Enter person details
Full Name: Rohan
Age: 21
Blood group: B-ve
Height: 1.23
Expected output:
Actual Output:
Then the person gives the screening test and after passing the test, he gets inducted.
Service Number and Rank are assigned to that person:
Input:
c
2. Capital of India was transferred from Calcutta to Delhi in the year:
a. 1901
b. 1911
c. 1921
d. 1922
b
3. The world's longest river is:
a. Brahmaputra
b. Amazon
c. Nile
d. Mississipi
c
4. Which of the following is not a union territory ?
a. Laddakh
b. Sikkim
c. Lakshadweep
d. Puducherry
b
5. Which one of the following does not remain to be a planet now ?
a. Neptune
b. Uranus
c. Pluto
d. Venus
c
Enter the details like service number,rank,enrollment date and service:
788546
Aircraftsmen
25/Apr/2020
AirForce
Expected Output:
Actual Output:
Input:
a
2. Capital of India was transferred from Calcutta to Delhi in the year:
a. 1901
b. 1911
c. 1921
d. 1922
d
3. The world's longest river is:
a. Brahmaputra
b. Amazon
c. Nile
d. Mississipi
c
4. Which of the following is not a union territory ?
a. Laddakh
b. Sikkim
c. Lakshadweep
d. Puducherry
c
5. Which one of the following does not remain to be a planet now ?
a. Neptune
b. Uranus
c. Pluto
d. Venus
Expected Output:
Actual Output:
2. Firing and reloading a gun: void fireGun(Gun *g), void reload(Gun *g)
Input:
Select an option
1. Fire a gun
2. Throw a grenade
3. Fly an aircraft
4. Submerge a submarine
5. Deploy a tank
6. Deploy a Warship
1
Enter gun name
M416
Enter the fullname to search
Ankit
Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
1
Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
2
Expected Output:
Ankit has fired the gun M416 and now the count of bullets in it is 39
Ankit has fired the gun M416 and now the count of bullets in it is 38
Ankit has fired the gun M416 and now the count of bullets in it is 37
Ankit has fired the gun M416 and now the count of bullets in it is 36
Actual Output:
Input:
Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
3
Expected Output:
Actual Output:
Input:
1
Enter gun name
AK51
Expected output:
Actual Output:
Input:
1
Enter gun name
M416
Enter the fullname to search
Ash
Expected Output:
10:Military personnel not found
Actual output:
Input:
Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
1
Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
1
Expected Output:
Ankit has fired the gun M416 and now the count of bullets in it is 0
Actual Output:
A person is assigned to a Fighter Jet. The flying of a fighter jet can be simulated using
this method:
Input:
Select an option
1. Fire a gun
2. Throw a grenade
3. Fly an aircraft
4. Submerge a submarine
5. Deploy a tank
6. Deploy a Warship
3
Enter Fighter Jet name
Tejas
Enter person name
Ankit
Ankit is flying the fighterjet Tejas
Expected Ouptut:
Actual Output:
Input:
Select an option
1. Fire a gun
2. Throw a grenade
3. Fly an aircraft
4. Submerge a submarine
5. Deploy a tank
6. Deploy a Warship
3
Enter Fighter Jet name
Mig-21
Expected Output:
Actual Output:
Input:
Expected Output:
Actual Output:
Input:
Expected Output:
Actual Output:
Input:
Expected Output:
Actual Output:
4. Results
1. Main Menu
2. Create person
3. Create a Base
4. Create submarine
5. Create Warship
6. Create Tank
7. Create FighterJet
9. Create gun
12. Recruitment
13. Training
V. Fly a FighterJet: