public override decimal CalculateCommission(RealEstateAgency rea, decimal price) { if (rea.yearBuilt < 1990) { if (rea.surface < 30 || rea.surface > 90) { throw new Exception("No apartments with this surface! Please introduce a valid value for surface(30-90 square meters)."); } else if (rea.surface <= 60) { return(price * 0.016m); } } else { if (rea.surface < 30 || rea.surface > 90) { throw new Exception("No apartments with this surface! Please introduce a valid value for surface(30-90 square meters)."); } else if (rea.surface <= 60) { return(price * 0.02m); } } throw new InvalidOperationException("Please verify year of construction of the apartment!"); }
public override decimal CalculateCommission(RealEstateAgency rea, decimal price) { if (rea.yearBuilt < 1990) { if (rea.surface < 15 || rea.surface > 30) { throw new Exception("No studios with this surface! Please introduce a valid value for surface(15-30 square meters)."); } else if (rea.surface <= 30) { return(price * 0.008m); } } else { if (rea.surface < 15 || rea.surface > 30) { throw new Exception("No studios with this surface! Please introduce a valid value for surface(15-30 square meters)."); } else if (rea.surface <= 30) { return(price * 0.012m); } } throw new InvalidOperationException("Please verify year of construction of the studio!"); }
public override decimal CalculateCommission(RealEstateAgency rea, decimal price) { if (rea.type.ToLower() == "urban") { if (rea.surface < 3000) { return(price * 0.02m); } else if (rea.surface > 3000 || rea.surface < 10000) { return(price * 0.035m); } else { return(price * 0.05m); } } else if (rea.type.ToLower() == "rural") { if (rea.surface < 3000) { return(price * 0.01m); } else if (rea.surface > 3000 || rea.surface < 10000) { return(price * 0.015m); } else { return(price * 0.03m); } } throw new Exception("Invalid type of land(Please verify that type are rural/urban)"); }
public override decimal CalculateCommission(RealEstateAgency rea, decimal price) { if (rea.floors < 1 || rea.floors > 3) { throw new Exception("No houses with " + rea.floors + " floor/floors. Please verifiy that dates are correct!"); } else if (rea.floors > 0 || rea.floors < 2) { if (rea.yearBuilt < 1990) { if (rea.surface < 50 || rea.surface > 350) { throw new Exception("No houses with this surface!Please introduce a valid value for surface(50-350 square meters)."); } else if (rea.surface <= 350) { return(price * 0.01m); } } else { if (rea.surface < 50 || rea.surface > 350) { throw new Exception("No houses with this surface!Please introduce a valid value for surface(50-350 square meters)."); } else if (rea.surface <= 350) { return(price * 0.015m); } } } else if (rea.floors >= 2 || rea.floors <= 3) { if (rea.yearBuilt < 1990) { if (rea.surface < 50 || rea.surface > 350) { throw new Exception("No houses with this surface!Please introduce a valid value for surface(50-350 square meters)."); } else if (rea.surface <= 350) { return(price * 0.015m); } } else { if (rea.surface < 50 || rea.surface > 350) { throw new Exception("No houses with this surface!Please introduce a valid value for surface(50-350 square meters)."); } else if (rea.surface <= 350) { return(price * 0.025m); } } } throw new InvalidOperationException("Please verify the number of floors!"); }
static void Main() { RealEstateAgency rea = new RealEstateAgency(); Asset house = new House(); var housecommission = new HouseCommissionCalculator(); Asset apartment = new Apartment(); var apartmentcommission = new ApartmentCommissionCalculator(); Asset singleroom = new Singleroom(); var singleroomcommission = new SingleroomCommissionCalculator(); Asset field = new Field(); var fieldcommission = new FieldCommissionCalculator(); rea.CalculatePricefor(house, 130000m, "center", housecommission); rea.CalculatePricefor(apartment, 140000m, "periphery", apartmentcommission); rea.CalculatePricefor(singleroom, 13000m, "center", singleroomcommission); rea.CalculatePricefor(field, 150000m, "center", fieldcommission); }
public override decimal CalculateTotalPrice(RealEstateAgency rea, decimal price) { var apartmentCommisionCalculator = new ApartmentCommissionCalculator(); return(price + apartmentCommisionCalculator.CalculateCommission(rea, price)); }
public override decimal CalculateTotalPrice(RealEstateAgency rea, decimal price) { var studioCommisionCalculator = new StudioCommissionCalculator(); return(price + studioCommisionCalculator.CalculateCommission(rea, price)); }
public abstract decimal CalculateTotalPrice(RealEstateAgency rea, decimal price);
public abstract decimal CalculateCommission(RealEstateAgency rea, decimal price);