Ejemplo n.º 1
0
        /// <summary>
        /// Suranda pageidaujamus butus
        /// </summary>
        /// <param name="flats"></param>
        /// <param name="roomAmount"></param>
        /// <param name="maxprice"></param>
        /// <param name="minfloor"></param>
        /// <param name="maxfloor"></param>
        /// <returns></returns>
        private static FlatContainer FilteredFlats(FlatContainer flats, int roomAmount, double maxprice, int minfloor, int maxfloor)
        {
            FlatContainer filteredFlats = new FlatContainer(MaxFlatAmount);

            for (int i = 0; i < flats.Count; i++)
            {
                if (flats.GetFlat(i).Rooms == roomAmount)
                {
                    if (flats.GetFlat(i).Price <= maxprice)
                    {
                        Console.WriteLine(flats.GetFlat(i).Floor);
                        if (flats.GetFlat(i).Floor >= minfloor && flats.GetFlat(i).Floor <= maxfloor)
                        {
                            filteredFlats.AddFlat(flats.GetFlat(i));
                        }
                    }
                }
            }
            return(filteredFlats);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Nuskaito failo duomenis
        /// </summary>
        /// <param name="flats"></param>
        private static void ReadFlatData(FlatContainer flats)
        {
            using (StreamReader reader = new StreamReader(@"Sav.D.1.Data.csv"))
            {
                string line = null;
                line = reader.ReadLine();

                while (null != (line = reader.ReadLine()))
                {
                    string[] values = line.Split(';');
                    int      number = int.Parse(values[0]);
                    double   area   = double.Parse(values[1]);
                    int      rooms  = int.Parse(values[2]);
                    double   price  = double.Parse(values[3]);
                    string   phone  = values[4];

                    Flat flat = new Flat(number, area, rooms, price, phone);

                    flats.AddFlat(flat);
                }
            }
        }