GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Classes definitions and implementation in Java

<!--[if gte mso 9]> Normal 0 false false false EN-US X-NONE X-NONE <![endif]-->

Could someone show the Java code for the following classes:

Shape bots are robots that can be shown in different shapes - triangle, rectangle, hexagon and circle. Each robot has a name, dimensions (that are assigned during the creation of Shape bot), strength (that is computed as the product of their surface and randomly generated number from 1 to 100), and the ability to transform (rectangle can transform to triangle such that it is halved by diagonal, and isosceles triangle is formed by merging two halves of a rectangle. Two triangles can be transformed in a rectangle only if they are right angled and have equal sides.). Robots of the shape of a triangle can fly, those of the shape of a circle can swim, and rest of them can walk and fly. According to this, they can be on a particular position in a 40 X 20 matrix. Shape bots have their enemies - Music bots, that can destroy Shape bots by singing. They can sing only if they are on the ground - otherwise they are automatically destroyed.

Matrix 40 X 20 is represented by:

10    Air

10 Water  Ground

    20     20

Air space is 40 X 10, Water space is 20 X 10, and Ground space is 20 X 10.


asked Mar 9, 2017 by anonymous