示例#1
0
    /// <summary>
    /// Returns a specific Weather class based on the value of parameter iRange
    /// </summary>
    /// <param name="iRange">Specific choice of Weather Object</param>
    /// <returns>wTempWeather</returns>
    public Weather RandomWeatherRange(int iRange)
    {
        Weather wTempWeather = new Weather();

        switch (iRange)
        {
        case 0:     //Rain
            wTempWeather = new Sunny();
            return(wTempWeather);

        case 1:     //Sunny
            wTempWeather = new Rain();
            return(wTempWeather);

        case 2:     //Cloudy
            wTempWeather = new Cloudy();
            return(wTempWeather);

        case 3:     //Snow
            wTempWeather = new Snow();
            return(wTempWeather);

        case 4:     //Windy
            wTempWeather = new Windy();
            return(wTempWeather);

        case 5:     //Thunderstorm
            wTempWeather = new Thunderstorm();
            return(wTempWeather);

        case 6:     //Hail
            wTempWeather = new Hail();
            return(wTempWeather);

        case 7:     //Fog
            wTempWeather = new Fog();
            return(wTempWeather);

        case 8:     //HeatWave
            wTempWeather = new HeatWave();
            return(wTempWeather);
        }

        return(wTempWeather);
    }
示例#2
0
        /// <summary>
        /// This is an example of a program that makes use of a DLL created
        /// in a different project in the same solution.  It also makes use
        /// (in Intellisense) of the method documentation.  To make this work,
        /// I right clicked on the project in Solution Explorer and added
        /// a reference to the Hailstone project
        ///
        /// The default visibility of a nested member of a class is private.
        /// </summary>
        static void Main()
        {
            // This shows how to consume the integers produced by
            // the result of Hail.ailstone(7), which is an IEnumerable<int>.
            foreach (int n in Hail.Hailstone(7))
            {
                Console.WriteLine(n);
            }

            // Obtains and prints the first item in the sequence.
            Console.WriteLine(Hail.Hailstone(7).First());

            // Obtains and prints the largest item in the sequence.
            Console.WriteLine(Hail.Hailstone(7).Max());

            // Prints the reverse of the sequence
            foreach (int n in Hail.Hailstone(7).Reverse())
            {
                Console.WriteLine(n);
            }
        }
示例#3
0
    public static void hail_test( )

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HAIL_TEST tests HAIL.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("HAIL_TEST");
        Console.WriteLine("  HAIL(I) computes the length of the hail sequence");
        Console.WriteLine("  for I, also known as the 3*N+1 sequence.");
        Console.WriteLine("");
        Console.WriteLine("  I,  HAIL(I)");
        Console.WriteLine("");

        for (i = 1; i <= 20; i++)
        {
            Console.WriteLine("  "
                              + i.ToString().PadLeft(4) + "  "
                              + Hail.hail(i).ToString().PadLeft(6) + "");
        }
    }