trainings/CreatingReliableSoftwareCpp/Presentation/exercises/strategy/README.md

38 lines
No EOL
1.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Linux compilation
> mkdir build
> cd build
> cmake -DCMAKE_BUILD_TYPE=Debug ..
> make
## Exercise 1
* Go into directory Core and implement ShipStrategy as a template class
* Strategy should have one pure virtual function: Res handle(T&)
* Implement in directory Ship class ShipEasyDifficultLvlStrategy
* Each cargo supplies 2 sailors, so if you have 40 crew, you need 20 banas and 20 rum
* Implement NextDay by using strategy class
* Run code, and verify result
## Exercise 2
* Implement in directory *Player* class *PalyerEasyDifficultLvlStrategy*
    * Strategy should roll a die (1-20):
    * If result is lower than 5 -> 0 DMG
    * If result is higher than 19 -> multiple damage by 2
    * Damage should be rolled from (25 to 50)
    * deal damage to the ship and return how much damage was deal. Print it in console
* Add all necessary implementation to the *Enemy* file
* Test it
## Exercise 3
* Implement tow new classes *EnemyHardDifficultLvlStrategy* and *ShipHardDifficultLvlStrategy*
* Strategy for Ship, should subtract cargo equal crew size
    * Strategy for Enemy should roll a die (1-20):
    * If result is lower than 3 -> 0 DMG
* If result is higher than 15 but not equal 20 -> multiple damage by 3
    * If result is higher than 19 -> multiple damage by 3
    * Damage should be rolled from (30 to 60)
* You shouldn't modify any existing file, except the main.cpp, where you should use a new strategy
* Run code and verify the result