Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the Mode class.
        /// </summary>
        /// <param name="title">The name of the Mode object.</param>
        /// <param name="abbreviation">The key for the Mode object (has to be unique among them).</param>
        /// <param name="uniqueChars">The keys that are already in use to prevent not calling the second mode with the same abbreviation.</param>
        /// <param name="lotto">The Lottery variable that should be used.</param>
        /// <exception cref="ArgumentNullException">If the title has no actual name or the unique char array is null.</exception>
        /// <exception cref="ArgumentException">If the abbreviation has already be used.</exception>
        public Mode(string title, char abbreviation, char[] uniqueChars, Lottery lotto)
        {
            if (uniqueChars == null)
            {
                throw new ArgumentNullException(nameof(uniqueChars));
            }

            for (int i = 0; i < uniqueChars.Length; i++)
            {
                if (uniqueChars[i] == abbreviation)
                {
                    throw new ArgumentException("The same abbreviation must not be used multiple times!", nameof(abbreviation));
                }
            }

            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentNullException(nameof(title), $"The title of the mode with the character {abbreviation} must have a name.");
            }

            for (int i = 0; i < uniqueChars.Length; i++)
            {
                if (uniqueChars[i] == '\0')
                {
                    uniqueChars[i] = abbreviation;
                    break;
                }
            }

            this.Title        = title;
            this.Abbreviation = abbreviation;
            this.Lotto        = lotto;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the Mode objects and puts them into an array of modes.
        /// </summary>
        /// <param name="lotto">The Lottery variable that should used.</param>
        /// <returns>The array of the initialized mode objects.</returns>
        public Mode[] CreateModes(Lottery lotto)
        {
            Mode[] modeOptions = new Mode[6];
            char[] uniqueChars = new char[modeOptions.Length];

            modeOptions[0] = new ManualTip("Manual Tip", 'M', uniqueChars, lotto);
            modeOptions[1] = new QuickTip("Quick Tip", 'Q', uniqueChars, lotto);
            modeOptions[2] = new GraphicalTip("Graphical Tip", 'G', uniqueChars, lotto);
            modeOptions[3] = new JackpotSimulation("Jackpot Simulation", 'S', uniqueChars, lotto);
            modeOptions[4] = new DetermineFrequencies("Determine Frequencies", 'H', uniqueChars, lotto);
            modeOptions[5] = new ExitApp("Application Extermination", 'B', uniqueChars, lotto);

            return(modeOptions);
        }
 /// <summary>
 /// Initializes a new instance of the JackpotSimulation class.
 /// </summary>
 /// <param name="title">The name/title of the Mode.</param>
 /// <param name="abbreviation">The specified key, the user has to press to get lead to this mode.</param>
 /// <param name="uniqueChars">The already used keys to prevent to not get to this mode.</param>
 /// <param name="lotto">The Lottery variable with all necessary classes this mode needs.</param>
 public JackpotSimulation(string title, char abbreviation, char[] uniqueChars, Lottery lotto) :
     base(title, abbreviation, uniqueChars, lotto)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the DetermineFrequencies class.
 /// </summary>
 /// <param name="title">The name/title of the Mode.</param>
 /// <param name="abbreviation">The specified key, the user has to press to get lead to this mode.</param>
 /// <param name="uniqueChars">The already used keys to prevent to not get to this mode.</param>
 /// <param name="lotto">The Lottery variable with all necessary classes this mode needs.</param>
 public DetermineFrequencies(string title, char abbreviation, char[] uniqueChars, Lottery lotto) :
     base(title, abbreviation, uniqueChars, lotto)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the QuickTip class.
 /// </summary>
 /// <param name="title">The name/title of the Mode.</param>
 /// <param name="abbreviation">The specified key, the user has to press to get lead to this mode.</param>
 /// <param name="uniqueChars">The already used keys to prevent to not get to this mode.</param>
 /// <param name="lotto">The Lottery variable with all necessary classes this mode needs.</param>
 public QuickTip(string title, char abbreviation, char[] uniqueChars, Lottery lotto) :
     base(title, abbreviation, uniqueChars, lotto)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the ExitApp class.
 /// </summary>
 /// <param name="title">The title of the object.</param>
 /// <param name="abbreviation">The key to get the user to the objects execute method.</param>
 /// <param name="uniqueChars">The keys that are already used to prevent not being able to call the second mode with the same abbreviation.</param>
 /// <param name="lotto">The Lottery variable that should be used.</param>
 public ExitApp(string title, char abbreviation, char[] uniqueChars, Lottery lotto) : base(title, abbreviation, uniqueChars, lotto) // Constructor
 {
 }