Esempio n. 1
0
        /// <summary>
        /// Determines whether the specified <see cref="object"/> is equal to the current <see cref="T:willyOS.RWVideogame"/>.
        /// </summary>
        /// <param name="obj">The <see cref="object"/> to compare with the current <see cref="T:willyOS.RWVideogame"/>.</param>
        /// <returns><c>true</c> if the specified <see cref="object"/> is equal to the current <see cref="T:willyOS.RWVideogame"/>;
        /// otherwise, <c>false</c>.</returns>
        public override bool Equals(object obj)
        {
            RWVideogame videogame = obj as RWVideogame;

            if (videogame == null)
            {
                return(false);
            }
            return(Title.Equals(videogame.Title));
        }
Esempio n. 2
0
        /// <summary>
        /// This method creates the specified number of videogames, using random data from the videogame list also provided
        /// </summary>
        /// <param name="numberOfVideogames">Number of videogames to be created</param>
        /// <returns>An array of Videogame instances, fully instantiated from the videogame data</returns>
        public static RWVideogame[] CreateRandomVideoGames(int numberOfVideogames = 100)
        {
            RWVideogame[] listing = new RWVideogame[numberOfVideogames];
            Random        random  = new Random();

            string[,] data = null;
            VidegamePlatform platform = VidegamePlatform.PS3;

            for (int i = 0; i < numberOfVideogames; i++)
            {
                int platformNumber = random.Next(0, 3);
                if (platformNumber == 0)
                {
                    data     = RAVideogameGeneratorData.Ps3Games;
                    platform = VidegamePlatform.PS3;
                }

                if (platformNumber == 1)
                {
                    data     = RAVideogameGeneratorData.XBox360Games;
                    platform = VidegamePlatform.Xbox360;
                }

                if (platformNumber == 2)
                {
                    data     = RAVideogameGeneratorData.WiiGames;
                    platform = VidegamePlatform.Wii;
                }

                int gameNumber = random.Next(0, data.GetLength(0));

                int year = 2020;
                try {
                    year = int.Parse(data[gameNumber, 2]);
                } catch (Exception) { };
                listing[i] = new RWVideogame {
                    Title               = data[gameNumber, 0],
                    Platform            = platform,
                    Year                = year,
                    Genre               = data[gameNumber, 3],
                    Editor              = data[gameNumber, 4],
                    AmericaSales        = double.Parse(data[gameNumber, 5].Replace(".", ",")),
                    EuropeSales         = double.Parse(data[gameNumber, 6].Replace(".", ",")),
                    JapanSales          = double.Parse(data[gameNumber, 7].Replace(".", ",")),
                    RestOfTheWorldSales = double.Parse(data[gameNumber, 8].Replace(".", ",")),
                    AvailableUnits      = random.Next(10, 100),
                };
            }
            return(listing);
        }