Interview related question doubt

Write a program that fulfills all the following requirements.

Program Flow:

Trainer A has a Pikachu and Trainer B has a Squirtle
The two trainers will swap Pokémon.
Pokémon Features:

Create the Pokémon classes; Pikachu and Squirtle
It should be easy to extend to support other Pokémon types.
Pokémon attributes and behavior
a. Life Points - A “life” value that will be initialized to a random value
between 50 and 100 at time of creation.
b. Attack - When it attacks, the attack value is randomized between 25 and
40
c. Defend - When attacked, the defending Pokémon will have a 33% chance to
avoid (zero) damage. If not avoided the attack damage is taken from the
pokémon’s life points
Pikachu attributes and behavior
a. It has a 25% chance of increasing attack damage by 50%
Squirtle attributes and behavior
a. Avoid chance of 50%
b. Life value range of 70 - 100
Pokémon Trainer Features:

Create a trainer class with a name and pokémon partner

Please help me to solve this problem…It was asked in some interview

hello @Somasree

this problem is not dsa based instead its oops based problem where u have to make classes to achieve the desired task .

keep follwing things in mind while coding it
a) make use of proper getter and setters to make sure the mentioned constraints not get voilated
b) inheritence and interfaces to support multiple pokemons
c) attributes-> life points and its access specifier
d) behaviour i,e member functions attack , defend
e) constructors

These types of questions are asked for the freshers or a intern at top mnc???Also what are getters and setters???

its very company specific thing (like google asks only dsa ) . read past interview experience of companies that u r targeting (from gfg) u will get fair idea what is beign asked .

but yeah oops concepts (not like above one) get asked in most of the interviews so prepare it as well .

setter and getters are nothing but functions in classes.
the purpose of setter is to set variables of class with some value(for example setName function in a student class).
and the purpose of getter is to get value of variable of class (for example getName function in a student class).

thank u so much sir .Helped a lot

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.