4A21 - 56 - 63 - Armed Forces - CaseStudy02

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 49

Armed Forces

KLE Society's
KLE Technological University

Open Ended Activity Report


On
Armed Forces
Object Oriented Programming with C++ (19ECSC204)
Object Oriented Programming with C++ Lab (18ECSP203)

Submitted by

Name Roll no SRN


Atul Kumar 56 01FE18BCS056

Isha Bhandary 63 01FE18BCS063

Team Number: 4A21

Faculty In-charge:

K M M Rajashekharaiah

SCHOOL OF COMPUTER SCIENCE & ENGINEERING


HUBLI – 580 031 (India).
Academic year 2019-20

School of Computer Science and Engineering 4A21 Page 1


Armed Forces

1. Introduction
1.1 Overview of the Problem Statement

1.2 Features of Application

1.2.1 Recruitment of Military Personnel

1.2.2 Prepare for a War

1.2.3 Simulate a War

2. Design

2.1 Class Diagram

2.2 Description of Each Class

2.3 Main Function

2.4 Use of Standard Design Patterns

3. Unit Test Plan

3.1 Recruitment: void recruitment(Person p)

3.2 Firing and reloading a gun: void fireGun(Gun *g), void reload(Gun *g)

3.3 Flying a Fighter Jet: void fly(FighterJet *fj)

3.4 Training: void training(MilitaryPersonnel *mp)

4 Implementation

4.1 Results

School of Computer Science and Engineering 4A21 Page 2


Armed Forces

1. Introduction

i. Overview of Problem Statement

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.

ii. Features of Application

1. Recruitment of Military Personnel


A person can be recruited by providing his basic details and answering some questions. The
details of the person are checked for the eligibility criteria and a few questions are asked. If
the Person is eligible, then that person can give induction test. After passing the induction
test, the person is inducted into any one of the forces and he is given a service number and a
rank.

School of Computer Science and Engineering 4A21 Page 3


Armed Forces

2. Prepare for a War


In prepare for war ,the user can train Military Personnel. Either a particular personnel can be
trained or all of them can be trained. He can create vehicles such as tanks, submarines,
fighter jets and warships. There is also an option to create artillery like guns and grenades to
be used in the war.

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.

School of Computer Science and Engineering 4A21 Page 4


Armed Forces

2. Design

i. Class Diagram

School of Computer Science and Engineering 4A21 Page 5


Armed Forces

School of Computer Science and Engineering 4A21 Page 6


Armed Forces

School of Computer Science and Engineering 4A21 Page 7


Armed Forces

ii. Description of Each Class


1. ArmedForce

ArmedForce
<<abstract>>

+bases[]:*Base
+mp[]:*MilitaryPersonnel
+ar[]:*Artillery
+v[]: * Vehicle
-mpno:int

+training(MilitaryPersonnel):void
+induction(Person):void
+virtual recruitment(Person):void=0

 This is an Abstract class where we have a pure virtual function “recruitment()”


which is used for recruiting persons into a particular force if they clear the
recruitment process.
 It has 3 sub-classes: Navy, Army & AirForce.
 The classes like Base,MilitaryPersonnel,Artillery and Vehicle aggregrate from it.

2. Navy

 It is a singleton class as it has only one object.


 The recruitment function is overridden from ArmedForce class.

School of Computer Science and Engineering 4A21 Page 8


Armed Forces

3. Army

 It is a singleton class as it has only one object.

 The recruitment function is overridden from ArmedForce class.

4. AirForce

 It is a singleton class as it has only one object

 The recruitment function is overridden from ArmedForce class.

School of Computer Science and Engineering 4A21 Page 9


Armed Forces

5. Vehicle

 This is an Abstract class where we have a pure virtual function “printVehicle()”


 It creates the type of vehicle as per demands of the user.
 It has 4 sub-classes: Tank, Submarine, FighterJet & WarShip

6. Tank, WarShip, FighterJet and Submarine

School of Computer Science and Engineering 4A21 Page 10


Armed Forces

 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

 This is an Abstract class where we have a pure virtual function


“printArtillery()”.
 It creates the type of artillery as per the demands of the user.
 It has 2 sub-classes: Gun and Grenade.

School of Computer Science and Engineering 4A21 Page 11


Armed Forces

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

School of Computer Science and Engineering 4A21 Page 12


Armed Forces

 This class describes bases all over the country.


 It has arrays of MilitaryArea and ResidentialArea.(Composition)

10. ResidentialArea, MilitaryArea

 The above classes aggregate from class Base.


 MilitaryArea has array of vehicles and artillery and
ResidentialArea has array of military personnel.
 Once a vehicle or artillery is created, the user can decide which
military area to place them in.

10. Person

School of Computer Science and Engineering 4A21 Page 13


Armed Forces

 It is base class for MilitaryPersonnel.


 A person can register for the recruitment process and if he is selected he
gets inducted into the armed force.

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

This class is used to display the appropriate error messages to user.

School of Computer Science and Engineering 4A21 Page 14


Armed Forces

iii. Main Function


In main function we create a single object of Army, AirForce and Navy.

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.

iv. Use of Standard Design Patterns

Factory design pattern and singleton pattern are used for the above application.
• Factory method pattern(creational pattern):

• Definition:- The Factory Method pattern is a design pattern used to


define a runtime interface for creating an object. It’s called a factory because
it creates various types of objects without necessarily knowing what kind of
object it creates or how to create it.
• Usage:- Factory method is suitable for this scenario because vehicle
objects are to be created as per user demand, so to create the objects of the
required vehicle type during the run time interface it becomes easier.
Similarly artillery are to be created as per the requirements of the armed
forces.

• Singleton Pattern(creational pattern):

• Definition:- This type of design pattern comes under creational pattern


as this pattern provides one of the best ways to create an object.
This pattern involves a single class which is responsible to create an
object while making sure that only single object gets created. This class
provides a way to access its only object which can be accessed directly
without need to instantiate the object of the class.
• Usage:- Singleton pattern is suitable for this scenario because there
can be only one navy,army and airforce in the country.

School of Computer Science and Engineering 4A21 Page 15


Armed Forces

3. Unit Test plan

1. Recruitment: void recruitment(Person p)

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.

Given below is how a person gets inducted into a force:

First the details of the person are stored.

Then the person is asked for the force they want to join, and their eligibility is
checked:

Test case 1: Passing the Eligibility criteria

Input:

Welcome to recruitment drive

1. Create a person to recruit


2. Use a created person

1
Enter person details
Full Name: Ankit
Age: 18
Blood group: B+ve
Height: 1.88

School of Computer Science and Engineering 4A21 Page 16


Armed Forces

Select the force:


1. Army
2. AirForce
3. Navy
2
Enter y for yes and n for no for the following:
1. Educational qualification: Passed Intermediate with Mathematics, Physics and
English with minimum 50% marks in aggregate and 50% marks in English.
y
2. Marital status:
n
3. Without glasses better eye 6/6 and worse eye 6/9 and not colour blind and not
suffering from night blindness:
y
4. Good mental and physical health free from any disease/disability.
y
5. Permanent body tattoos other than on inner face of the fore arms
n

Expected output:

Person "Ankit" created successfully.

You are eligible for screening test

Actual output:

School of Computer Science and Engineering 4A21 Page 17


Armed Forces

Test case 2: Failing the Eligibility criteria

Input:

Welcome to recruitment drive

1. Create a person to recruit


2. Use a created person

1
Enter person details
Full Name: Rohan
Age: 21
Blood group: B-ve
Height: 1.23

Select the force:


1. Army
2. AirForce
3. Navy
2
1. Educational qualification: Passed Intermediate with Mathematics, Physics and
English with minimum 50% marks in aggregate and 50% marks in English.
y
2. Marital status:
n
3. Without glasses better eye 6/6 and worse eye 6/9 and not colour blind and not
suffering from night blindness:
y
4. Good mental and physical health free from any disease/disability.
y
5. Permanent body tattoos other than on inner face of the fore arms
n

Expected output:

Person "Rohan" created successfully.

You are not eligible for screening test

School of Computer Science and Engineering 4A21 Page 18


Armed Forces

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:

Test case 3: Passing the induction test

Input:

Enter "ok" to take the test:


ok
Answer the following MCQ type questions by entering the options:
1. The High Courts at Calcutta, Madras and Bombay were established under the
a. Indian High Courts Act, 1911
b. Government of India Act, 1909
c. Indian High Courts Act, 1861
d. Indian High Courts Act, 1865

c
2. Capital of India was transferred from Calcutta to Delhi in the year:
a. 1901
b. 1911
c. 1921
d. 1922

School of Computer Science and Engineering 4A21 Page 19


Armed Forces

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:

Person "Ankit" inducted into AirForce successfully.


The person details are:
Ankit:18:1.88:B+ve
788546:Aircraftsmen:25/Apr/2020:AirForce

School of Computer Science and Engineering 4A21 Page 20


Armed Forces

Actual Output:

School of Computer Science and Engineering 4A21 Page 21


Armed Forces

Test case 4: Failing the induction test:

Input:

Enter "ok" to take the test:


ok
Answer the following MCQ type questions by entering the options:
1. The High Courts at Calcutta, Madras and Bombay were established under the
a. Indian High Courts Act, 1911
b. Government of India Act, 1909
c. Indian High Courts Act, 1861
d. Indian High Courts Act, 1865

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

School of Computer Science and Engineering 4A21 Page 22


Armed Forces

Expected Output:

You failed the test

Actual Output:

2. Firing and reloading a gun: void fireGun(Gun *g), void reload(Gun *g)

A person is assigned a gun to participate in war activities. He can fire it in single


mode or burst mode. The gun can be reloaded once it has been fired.

Assigning of a gun to a person:

School of Computer Science and Engineering 4A21 Page 23


Armed Forces

Test case 5: Firing of gun in single and burst mode:

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)

School of Computer Science and Engineering 4A21 Page 24


Armed Forces

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:

Test case 6: Reloading of the gun:

Input:

Select an option
1. Fire single
2. Fire in Burst mode(3 bullets)
3. Reload
4. Exit
3

Expected Output:

School of Computer Science and Engineering 4A21 Page 25


Armed Forces

The Gun is reloaded. The number of bullets are:41

Actual Output:

Test case 7: Gun not found:

Input:

Select the option


1. Prepare for War
2. Perform War Activities
2
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
AK51

Expected output:

8:Gun not found

School of Computer Science and Engineering 4A21 Page 26


Armed Forces

Actual Output:

Test case 8: Military Personnel not found:

Input:

Select the option


1. Prepare for War
2. Perform War Activities
2
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
Ash

Expected Output:
10:Military personnel not found

School of Computer Science and Engineering 4A21 Page 27


Armed Forces

Actual output:

Test case 9: Bullets became zero

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

2: This gun has zero bullets

School of Computer Science and Engineering 4A21 Page 28


Armed Forces

Actual Output:

3. Flying a Fighter Jet: void fly(FighterJet *fj)

A person is assigned to a Fighter Jet. The flying of a fighter jet can be simulated using
this method:

Test case 10: Assigning Fighter Jet to person and flying:

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:

Ankit is flying the fighterjet Tejas

School of Computer Science and Engineering 4A21 Page 29


Armed Forces

Actual Output:

Test case 11: Fighter Jet not found:

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:

11:Fighterjet not found

Actual Output:

School of Computer Science and Engineering 4A21 Page 30


Armed Forces

4. Training: void training(MilitaryPersonnel mp)

An already inducted MilitaryPersonnel undergoes training. The method can be used


to train one person at a time or all the persons at one go.

Test case 12: Training one person at a time:

Input:

Select the option


1. Train a particular person
2. Train all
3. Create vehicles
4. Create Artillery
5. Exit
1
Enter the fullname to search
Ankit

Expected Output:

Military personnel Ankit is undergoing training.

School of Computer Science and Engineering 4A21 Page 31


Armed Forces

Actual Output:

Test case 13: Person not found:

Input:

Select the option


1. Train a particular person
2. Train all
3. Create vehicles
4. Create Artillery
5. Exit
1
Enter the fullname to search
Ash

Expected Output:

10:Military personnel not found

Actual Output:

School of Computer Science and Engineering 4A21 Page 32


Armed Forces

Test case 14: Training all persons at one go:

Input:

Select the option


1. Train a particular person
2. Train all
3. Create vehicles
4. Create Artillery
5. Exit
2

Expected Output:

Military personnel Ash is undergoing training.


Military personnel Alok is undergoing training.

Actual Output:

School of Computer Science and Engineering 4A21 Page 33


Armed Forces

4. Results

1. Main Menu

Exception handling in main menu:

School of Computer Science and Engineering 4A21 Page 34


Armed Forces

2. Create person

3. Create a Base

School of Computer Science and Engineering 4A21 Page 35


Armed Forces

4. Create submarine

5. Create Warship

School of Computer Science and Engineering 4A21 Page 36


Armed Forces

6. Create Tank

7. Create FighterJet

School of Computer Science and Engineering 4A21 Page 37


Armed Forces

8. Exception handling in Create Vehicles if a military area is not found

9. Create gun

School of Computer Science and Engineering 4A21 Page 38


Armed Forces

10. Create a grenade

11. Exception handling in Create Artillery if a military area is not found

School of Computer Science and Engineering 4A21 Page 39


Armed Forces

12. Recruitment

School of Computer Science and Engineering 4A21 Page 40


Armed Forces

School of Computer Science and Engineering 4A21 Page 41


Armed Forces

13. Training

Single person training:

Training all people at once:

School of Computer Science and Engineering 4A21 Page 42


Armed Forces

14. War Functions

I. Insufficient preparations for war:

II. Deploy a Warship:

School of Computer Science and Engineering 4A21 Page 43


Armed Forces

Warship not found:

III. Submerge a submarine:

School of Computer Science and Engineering 4A21 Page 44


Armed Forces

Submarine not found:

IV. Deploy tank:

School of Computer Science and Engineering 4A21 Page 45


Armed Forces

Tank not found:

V. Fly a FighterJet:

School of Computer Science and Engineering 4A21 Page 46


Armed Forces

FighterJet not found:

VI. Fire a gun:

Firing of gun in single and burst mode:

School of Computer Science and Engineering 4A21 Page 47


Armed Forces

Reloading of the gun:

Gun not found:

School of Computer Science and Engineering 4A21 Page 48


Armed Forces

VII. Throwing Grenade

Grenade not found:

School of Computer Science and Engineering 4A21 Page 49

You might also like