kisame1313

Untitled

Jul 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. public class Kata
  2. {
  3.   public static string DuckDuckGoose ( Player [] players, int goose )
  4.         {
  5.             if ( goose <= players.Length )
  6.             {
  7.                 goose = goose > 0 ? goose - 1 : goose;
  8.                 return players [goose].Name;
  9.             }
  10.             else
  11.             {
  12.                 if ( goose % players.Length == 0 )
  13.                 {
  14.                     int arInd = players.Length == 0 ? 0 : players.Length - 1;
  15.                     return players [arInd].Name;
  16.                 }
  17.                 else
  18.                 {
  19.                     return players [goose % players.Length].Name;
  20.                 }
  21.             }
  22.         }
  23. public class Player
  24.   {
  25.   public string Name {get;set;}
  26.  
  27.   public Player (string name)
  28.     {
  29.       this.Name = name;
  30.     }
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment