Hey guys! I think we are being unfair to Jimmy Valavanis myself including.
We acused him of using bad programing approach, of making ineficent code, of spending more time coding somethink that we belive it could be done faster in our way (OOP aproach) and we done all this without any relavent facts. We haven't seen any of his coding. What gives us right to judge him in the way we do?
So why don't we alow him first to prove himself solving a real problem in practise and only then judge him.
I will present problem below (the problem can be easily solved using OOP aproach) and I hope Jimmy would be so kind to take some of his time to show us how he would solve it. Maybe we will even learn something from him. Isn't that the purpose of our comunity - to learn.
Now Jimmy if for some rason you don't want to publicly participate in this I still hope that you take some time and send me solution for the problem below using your approach. I would realy like to see how it can be done in procedural way becouse I cant imagine how myself. Maybe I will learn something.
The problem is as folows:
Lets say you are creating a strategy game. In this game there are several different unit types. Your goal is to write a code wich will define these unit types as specified below.
For the sake of simplicity lets say that the gameworld is respresented with two dimensional array (tiles). These are defined like so:
0 for unpasable terrain
1 for land terrain
2 water terrain
3 for deep water terrain
Unit types are like this:
1. Land unit capable of atacking other land units
2. Land unit capable of atacking air units
3. Air unit capable of atacking other air units
4. Air unit capable of atacking land units
5. Air units capable of atacking submersible units
6. Naval units capable of atacking other naval units
7. Naval units capable of atacking submersible units
8. Submersible units capable of atacking other submersible units
9. Submersible units capable of atacking naval units
10. Submersible units capable of atacking land units.
Your code also need to make sure that these units can move properly (prevent ilegal moves)
1. Land units can move only on land
2. Naval units can move only on water
3. Submersible units can only move in deep water when submerged
4. Air units can move anywhere
Naturally each units have his health so this should also be covered in your code.
If you wish I will show you all how I would solve this problem myself using OOP aproach. I could also try to explain the benefits of using OOP in this case.
Bookmarks