I have a code test question in php oops concept, can some one help me how to solve this?any reference to solve this?Please help

About This Test

The purpose of this code test is to show us your skills in:

• Knowledge of OOP concepts, and judicious use of them

• Algorithms and problem-solving

• Code structure and commenting

Please keep these aspects in mind as you develop your solution. Also, your chosen algorithm doesn’t

necessarily have to be the best you can think of, but one that you can implement in the allocated



All classes, methods and so on should be commented in PHPDoc format. and you should include a

generous comment block explaining your design for part 1 and your algorithm for part 2. To be

considered for this position, you will have to have completed at least part 1 of this exercise.


You are the admiral of a mighty space fleet comprised of 50 vessels. Your fleet consists of two major

types of vessels - support craft and offensive craft.

Vessels can all receive a command that tells them to move to a given set of co-ordinates.

There are three different types of support craft - refuelling, mechanical assistance and cargo. They

all carry a medical unit. Each vessel can receive orders related to each of the tasks it can carry out.

There are also three different types of offensive craft - battleships, cruisers and destroyers.

Battleships have 24 cannons, destroyers have 12 and cruisers have 6. Each offensive craft can

receive an attack command, which will fire all its cannons. They can also be instructed to raise their

shields. Finally, the fleet has a command ship, which is where you are. The command ship is one of

the battleships, and there is only one per fleet.


Define a set of data structures to accurately reflect this fleet. Make sure that new types of vessels

can be added to your fleet with minimal effort.


You are taking your fleet, made up of an equal number of offensive and support ships, to your

assigned deployment point when you are ambushed by enemy forces. Your defence tactic is to pair

each support ship with one offensive ship in order to share the offensive ship’s shield. Assuming a

two-dimensional layout with a maximum size of 100x100, write some code that is able to represent

your fleet location data and populate it with your 50 ships in random positions. Then, implement an

algorithm that generates 25 pairs of ships, and issues the commands to make the pairs occupy

adjacent positions on the grid by moving one or both ships. Your vessels need to assume this

defensive formation as quickly as possible, so you will need to find an algorithm that gives an

optimized set of pairs, but that is also quick to generate them.


Please also supply your answer to the following questions:

  1. What is the complexity of your algorithm (in big O notation)?

  2. How would you improve your algorithm?

  3. How would you adapt your algorithm to three dimensions?

How would that affect the complexity?


All classes, methods and so on should be commented in PHPDoc format. and you should include a generous comment block

50 vessels  _(Always a pair (support&offensive) )_
  vessel  -move-coordinate

     -type refuelling/mechanical-assistance/cargo
     -medical-unit = true
     -desination-coordinate order-received

     -type - battleship - 24 cannon
                        - command-ship true/false
           - cruiser(12 canon)
           - destroyer(6 canon)
     -attack-command fire-canon(true/false)
     -raise-shield true/false

You will have to learn how to use so-called constructors
Please start

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.