Exemplo n.º 1
0
        public int SequentialSearch(double searchValue)
        {
            int foundIndex = -1;

            for (int i = 0; i < Books.GetCount(); i++)
            {
                if (myBooks[i].Equals(searchValue))
                {
                    foundIndex = i;
                }
            }
            return(foundIndex);
        }
Exemplo n.º 2
0
        // this method just initializes the myBooks array, as well
        // as the starting book count
        public Books[] GetAllBooks()
        {
            Books[] myBooks = new Books[200];
            Books.SetCount(0);
            StreamReader inFile = new StreamReader(fileName);

            string[] input = File.ReadAllLines(fileName);
            foreach (string line in input)
            {
                string[] bookInfo = line.Split('#');
                myBooks[Books.GetCount()] = new Books(double.Parse(bookInfo[0]), bookInfo[1], bookInfo[2], bookInfo[3], double.Parse(bookInfo[4]), double.Parse(bookInfo[5]));
                Books.IncCount();
            }
            inFile.Close();
            return(myBooks);
        }
Exemplo n.º 3
0
 public void SortArray()
 {
     for (int i = 0; i < Books.GetCount() - 1; i++)
     {
         int minIndex = i;
         for (int j = i + 1; j < Books.GetCount(); j++)
         {
             if (myBooks[minIndex].CompareTo(myBooks[j]) > 0)
             {
                 minIndex = j;
             }
         }
         if (minIndex != i)
         {
             Swap(i, minIndex);
         }
     }
 }