Initial commit
This commit is contained in:
commit
593d8ebfea
30 changed files with 2206 additions and 0 deletions
109
BucketChain/Person.cs
Normal file
109
BucketChain/Person.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
namespace BucketChain;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a person working together with others in a bucket chain to extinguish a fire.
|
||||
/// </summary>
|
||||
public sealed class Person
|
||||
{
|
||||
// TODO
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new person.
|
||||
/// We are not interested in any specific details of the person,
|
||||
/// only the position in the chain is relevant.
|
||||
/// </summary>
|
||||
public Person()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets if the person currently has at least one bucket (forward or backward).
|
||||
/// </summary>
|
||||
public bool HasBucket => false; // TODO
|
||||
|
||||
/// <summary>
|
||||
/// Gets the left neighbor of the person. Can be null.
|
||||
/// </summary>
|
||||
// TODO
|
||||
// public Person? LeftNeighbor ...
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right neighbor of the person. Can be null.
|
||||
/// </summary>
|
||||
// TODO
|
||||
// public Person? RightNeighbor ...
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the last step in which this person performed a bucket move action.
|
||||
/// Each person can only move, at most, once per step.
|
||||
/// </summary>
|
||||
// TODO
|
||||
// public int LastStepPerformed ...
|
||||
|
||||
/// <summary>
|
||||
/// The person joins an existing bucket chain at a specific position.
|
||||
/// This position is defined by the passed person and the information if this person will join
|
||||
/// the chain on the left or right side of the passed person.
|
||||
/// If the passed person already had a neighbor at this side this person joins between them.
|
||||
/// </summary>
|
||||
/// <param name="neighbor">The neighbor in the bucket chain</param>
|
||||
/// <param name="isLeftNeighbor">If true the passed person will become the left hand side
|
||||
/// neighbor of this person; otherwise it will become the right hand side neighbor</param>
|
||||
public void JoinChain(Person neighbor, bool isLeftNeighbor)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to move the forward bucket along the chain towards the fire.
|
||||
/// The person negotiates with the right hand side neighbor.
|
||||
/// If that neighbor can accept a forward bucket it received it.
|
||||
/// They also check if the right hand side neighbor has a backward (towards the well)
|
||||
/// bucket. If this person is able to receive the backward bucket it receives it.
|
||||
/// If at least one bucket is exchanged both involved people are done for the current step.
|
||||
/// </summary>
|
||||
/// <param name="currentStep">Number of the current (chain) operation step</param>
|
||||
/// <returns>True if the move attempt produced no errors - this does not mean
|
||||
/// that a bucket was moved, only that no invalid state was detected; false otherwise</returns>
|
||||
public bool MoveBucket(int currentStep)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fights the passed fire with water from the forward bucket. This empties the bucket.
|
||||
/// After using it the now empty bucket is moved to the backward position.
|
||||
/// </summary>
|
||||
/// <param name="fire">The fire to throw water at</param>
|
||||
public void FightFire(Fire fire)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the passed well to fill the bucket.
|
||||
/// If this person currently has no empty bucket to fill but there are still unused buckets
|
||||
/// available for the chain a new bucket will be introduced with this method.
|
||||
/// If the person has no forward bucket but a backward bucket that one is filled.
|
||||
/// </summary>
|
||||
/// <param name="well">The well to use for filling the bucket</param>
|
||||
/// <param name="additionalBucket">A new bucket to use; can be null</param>
|
||||
public void UseWell(Well well, Bucket? additionalBucket)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a string representation of this person instance.
|
||||
/// Shows if the person has none, an empty or full bucket.
|
||||
/// If the person has both forward and backward buckets the forward bucket is displayed.
|
||||
/// </summary>
|
||||
/// <returns>String representation of the person</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
// TODO
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue