Esempio n. 1
0
        public static Spel[] sökSpelViaTitel(string sökfras)
        {
            Spel[] hittadeSpel = new Spel[spelInfo.Length];
            int    spel        = 0;

            for (int i = 0; i < spelInfo.Length; i++)
            {
                if (spelInfo[i].titel.ToLower().Contains(sökfras.ToLower()) || spelInfo[i].genre.ToLower().Contains(sökfras.ToLower()))
                {
                    hittadeSpel[spel++] = spelInfo[i];
                }
            }
            Spel[] hittadeSpelTrimmadVektor = new Spel[spel];
            for (int i = 0; i < spel; i++)
            {
                hittadeSpelTrimmadVektor[i] = hittadeSpel[i];
            }
            return(hittadeSpelTrimmadVektor);
        }
Esempio n. 2
0
        public static void LaddaInTitlar()
        {
            StreamReader infil = new StreamReader("SPEL.txt");
            string       rad   = infil.ReadLine();

            while (rad != null)
            {
                string[] fält = rad.Split('\t');
                Spel     game = new Spel();

                game.titel = fält[0];
                game.genre = fält[1];
                game.betyg = int.Parse(fält[2]);

                spelInfo = LäggTillSpelTillOrginalVektorn(spelInfo, game);

                rad = infil.ReadLine();
            }

            infil.Close();
        }