Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            House house1 = new House(RealEstateAgency.LocationType.Center, 150, true, true, true, true, true, 30000);

            house1.CalculatePrice(RealEstateAgency.LocationType.Center, 150, true, true, true, true, true, 30000);
            Console.WriteLine();
            house1.CalculateAgentFee(RealEstateAgency.LocationType.Center, 150, true, true, true, true, true, 0.03, 30000);

            Console.WriteLine("\n"); Console.WriteLine("\n");

            SingleRoom SG1 = new SingleRoom(RealEstateAgency.LocationType.Tudor, 80, true, false, false, true, true, 18000);

            SG1.CalculatePrice(RealEstateAgency.LocationType.Tudor, 80, true, false, false, true, true, 18000);
            Console.WriteLine();
            SG1.CalculateAgentFee(RealEstateAgency.LocationType.Tudor, 80, true, false, false, true, true, 0.01, 18000);

            Apartment apartment1 = new Apartment();

            apartment1.CalculatePrice(RealEstateAgency.LocationType.Bucium, 120, true, true, true, true, true, 25000);
            Console.WriteLine();
            apartment1.CalculateAgentFee(RealEstateAgency.LocationType.Bucium, 120, true, true, true, true, true, 0.02, 25000);

            string           filepath    = @"D:\.net projects\PooPrincipii\Buildings.txt";
            RealEstateAgency newBuilding = new RealEstateBuilding();

            newBuilding.CalculateFromFile(filepath);
        }
Ejemplo n.º 2
0
        //  protected abstract void CalculatePrice(LocationType location,double Surface,bool CompartmentType,bool ParkingSpace,bool Balcony, bool Floor, double BuildingBasicPrice);
        //protected abstract void CalculateAgentFee(LocationType location, double Surface, bool CompartmentType, bool ParkingSpace, bool Balcony, bool Floor,bool Furnished, double BasicFee, double BuildingBasicPrice);

        public void CalculateFromFile(string filepath)
        {
            if (filepath is null)
            {
                throw new ArgumentNullException(nameof(filepath));
            }

            else
            {
                List <RealEstateAgency> Buildings = new List <RealEstateAgency>();

                List <string> lines = File.ReadAllLines(filepath).ToList();
                foreach (string line in lines)
                {
                    string[] block = line.Split(",");
                    if (String.Compare(block[0], "House") == 0)
                    {
                        AgentHouseFee = 0.03;
                        House newHouse = new House();
                        newHouse.houseLocation   = block[1];
                        newHouse.Surface         = Convert.ToDouble(block[2]);
                        newHouse.Furnished       = Convert.ToBoolean(block[3]);
                        newHouse.CompartmentType = Convert.ToBoolean(block[4]);
                        newHouse.ParkingSpace    = Convert.ToBoolean(block[5]);
                        newHouse.Balcony         = Convert.ToBoolean(block[6]);
                        newHouse.Floor           = Convert.ToBoolean(block[7]);
                        newHouse.Price           = Convert.ToDouble(block[8]);

                        Buildings.Add(newHouse);
                    }
                    else if (String.Compare(block[0], "Apartment") == 0)
                    {
                        AgentApartmentFee = 0.02;
                        Apartment newApartment = new Apartment();
                        newApartment.apartmentLocation = block[1];
                        newApartment.Surface           = Convert.ToDouble(block[2]);
                        newApartment.Furnished         = Convert.ToBoolean(block[3]);
                        newApartment.CompartmentType   = Convert.ToBoolean(block[4]);
                        newApartment.ParkingSpace      = Convert.ToBoolean(block[5]);
                        newApartment.Balcony           = Convert.ToBoolean(block[6]);
                        newApartment.Floor             = Convert.ToBoolean(block[7]);
                        newApartment.Price             = Convert.ToDouble(block[8]);

                        Buildings.Add(newApartment);
                    }
                    else
                    {
                        AgentSingleRoomFee = 0.01;
                        SingleRoom newSingleRoom = new SingleRoom();
                        newSingleRoom.SingleRoomLocation = block[1];
                        newSingleRoom.Surface            = Convert.ToDouble(block[2]);
                        newSingleRoom.Furnished          = Convert.ToBoolean(block[3]);
                        newSingleRoom.CompartmentType    = Convert.ToBoolean(block[4]);
                        newSingleRoom.ParkingSpace       = Convert.ToBoolean(block[5]);
                        newSingleRoom.Balcony            = Convert.ToBoolean(block[6]);
                        newSingleRoom.Floor = Convert.ToBoolean(block[7]);
                        newSingleRoom.Price = Convert.ToDouble(block[8]);

                        Buildings.Add(newSingleRoom);
                    }
                }
                foreach (var building in Buildings)
                {
                    Console.WriteLine($"{building._locationType } {building.Surface } { building.Furnished} {building.CompartmentType} " +
                                      $"{building.ParkingSpace} {building.Balcony} {building.Floor} {building.Price}");
                }
            }
        }