marikalmuk / Tasks

0 stars 0 forks source link

Relay simulator #11

Closed romaneo closed 3 years ago

romaneo commented 3 years ago

Create a program that imitates a Relay race

Let's say our relay race consist of four different activities in the following order:

Each activity must have its own player. The new activity can be started only when the baton is passed

Programm limitation:

Learning materials:

romaneo commented 3 years ago

A few more useful links:

Guard clause: https://refactoring.guru/uk/replace-nested-conditional-with-guard-clauses https://medium.com/@scadge/if-statements-design-guard-clauses-might-be-all-you-need-67219a1a981a

An array of abstract class type: https://cs.stackexchange.com/questions/46984/creating-arrays-of-object-of-abstract-class-in-statically-typed-object-oriented

Further readings: https://metanit.com/sharp/tutorial/3.12.php

romaneo commented 3 years ago

Please check the program output:

image

romaneo commented 3 years ago

Now it works fine.

Note, here is another "cleaner" way to implement this fix: image image

This implementation actively uses this pointer. As a result, you do not need to retrieve data of previous (sender) player inside of the current (this)

If no questions anymore, please merge this branch to the main and close the issue