Help needed with code test question in php oops concept

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

time.

Instructions

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.

BACKGROUND

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.

PART 1 - RECOMMENDED TIME: 45 MINUTES

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.

PART 2 - RECOMMENDED TIME: 1 HOUR AND 15 MINUTES

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.

Questions

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?

Hi mark2016 welcome to the forum

There is Reference for PHP OOP and phpDocumentor syntax

http://php.net/manual/en/language.oop5.php

https://phpdoc.org/docs/latest/references/phpdoc/basic-syntax.html

But I am fairly certain there will not be any reference for crafting an algorithm for those specifications.

Nothing personal, but if this is a test for a course and you are not already familiar with those references I’d say your instructor failed you by not introducing them early on.

Thank you so much Mittineague for the help,i haven’t worked in core php oops concept , creating any algorithms and all, i worked in code-igniter framework only.I do not have any idea how to answer this test.Do i need to create an application or create classes for each requirements and comment specifically or some other things.Could you please help me to figure out a brief idea about this test and solution they are expecting.

Wouldn’t it be best to talk to your instructor?

I know it may feel like you’re exposing a personal fault of some type, but in my experience they’ve always been more than willing to explain the requirements and may even respect your honesty for asking.

HI Mark2016,

I Got the same test. Have you solved the one ?

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