示例#1
0
        static void Main(string[] args)
        {
            var    studioCommisionCalculator    = new StudioCommissionCalculator();
            var    studioTotalPriceCalc         = new StudioTotalPriceCalculator();
            var    apartmentCommisionCalculator = new ApartmentCommissionCalculator();
            var    apartmentTotalPriceCalc      = new ApartmentTotalPriceCalculator();
            var    houseCommisionCalculator     = new HouseCommissionCalculator();
            var    houseTotalPriceCalc          = new HouseTotalPriceCalculator();
            var    landCommisionCalculator      = new LandCommissionCalculator();
            var    landTotalPriceCalc           = new LandTotalPriceCalculator();
            Studio studio = new Studio(25000m, 20, 1985, "Str.Salciilor,nr.2");


            RealEstatePrice.GetTotalPriceFrom(studio, studio.price, studioTotalPriceCalc);
            RealEstatePrice.GetCommissionFrom(studio, studio.price, studioCommisionCalculator);
            Console.WriteLine("The address of studio: " + studio.address);
            //Console.WriteLine("Studio price:{0} and commission:{1} Address of studio:{2} .",studioTotalPriceCalc.CalculateTotalPrice(studio,studio.price),studioTotalPriceCalc.CalculateTotalPrice(studio,studio.price) ,studio.address);
            Apartment apartment = new Apartment(65000m, 45, 1990, "Str.Vamesilor, nr.5");

            RealEstatePrice.GetTotalPriceFrom(apartment, apartment.price, apartmentTotalPriceCalc);
            RealEstatePrice.GetCommissionFrom(apartment, apartment.price, apartmentCommisionCalculator);
            Console.WriteLine("The address of apartment: " + apartment.address);
            //Console.WriteLine("Apartment price:" + apartmentTotalPriceCalc.CalculateTotalPrice(apartment,apartment.price) + " and commission: " +apartmentCommisionCalculator.CalculateCommission(apartment,apartment.price));
            House house = new House(70000m, 70, 2014, 3, "Str.Lalelelor, Horpaz");

            RealEstatePrice.GetTotalPriceFrom(house, house.price, houseTotalPriceCalc);
            RealEstatePrice.GetCommissionFrom(house, house.price, houseCommisionCalculator);
            Console.WriteLine("The address of house: " + house.address);
            //Console.WriteLine("House price:" + houseTotalPriceCalc.CalculateTotalPrice(house, house.price) + " and commission: " + houseCommisionCalculator.CalculateCommission(house, house.price));
            Land land = new Land(40000m, "URBAN", 1245, 1005000);

            RealEstatePrice.GetTotalPriceFrom(land, land.price, landTotalPriceCalc);
            RealEstatePrice.GetCommissionFrom(land, land.price, landCommisionCalculator);
            Console.WriteLine("The cadastral number of " + land.type.ToLower() + " land: " + land.cadastral_number);
            //Console.WriteLine("Land price:" + landTotalPriceCalc.CalculateTotalPrice(land, land.price) + " and commission: " + landCommisionCalculator.CalculateCommission(land, land.price));
        }
示例#2
0
        static void Main(string[] args)
        {
            string estate;
            int    sf;
            string location;

            Console.WriteLine("Welcome!!");
            Console.WriteLine("Tell us what tipe of place you are looking for.");
            Console.WriteLine("House");
            Console.WriteLine("Apartment");
            Console.WriteLine("SingleRoom");
            Console.WriteLine("Land");
            estate = Console.ReadLine();
            if (estate == "House")
            {
                Console.WriteLine("How many square feet do you want your house to be ?");
                sf = int.Parse(Console.ReadLine());
                Console.WriteLine("Choose the location you prefer (center or suburbs)");
                location = Console.ReadLine();
                House house = new House(sf, location);

                var price      = new HouseBasePrice();
                var calculator = new HouseComissionCalculator();

                Prices.GetLocation(house, location);
                Prices.GetInitialPrice(house, price);
                Prices.GetComission(house, calculator, price);
                Prices.GetPrice(house, calculator, price);
            }
            if (estate == "Apartment")
            {
                Console.WriteLine("How many square feet do you want your house to be ?");
                sf = int.Parse(Console.ReadLine());
                Console.WriteLine("Choose the location you prefer (center or suburbs)");
                location = Console.ReadLine();
                Apartment apartment = new Apartment(sf, location);

                var price      = new ApartmentBasePrice();
                var calculator = new ApartmentComissionCalculator();

                Prices.GetLocation(apartment, location);
                Prices.GetInitialPrice(apartment, price);
                Prices.GetComission(apartment, calculator, price);
                Prices.GetPrice(apartment, calculator, price);
            }
            if (estate == "SingleRoom")
            {
                Console.WriteLine("How many square feet do you want your house to be ?");
                sf = int.Parse(Console.ReadLine());
                Console.WriteLine("Choose the location you prefer (center or suburbs)");
                location = Console.ReadLine();
                SingleRoom singleroom = new SingleRoom(sf, location);

                var price      = new SingleRoomBasePrice();
                var calculator = new SingleRoomComissionCalculator();

                Prices.GetLocation(singleroom, location);
                Prices.GetInitialPrice(singleroom, price);
                Prices.GetComission(singleroom, calculator, price);
                Prices.GetPrice(singleroom, calculator, price);
            }
            if (estate == "Land")
            {
                Console.WriteLine("How many square feet do you want your house to be ?");
                sf = int.Parse(Console.ReadLine());
                Console.WriteLine("Tell us the cadastral number: 4578/ 3463/ 2098");
                int  cadastral_nr = int.Parse(Console.ReadLine());
                Land land         = new Land(sf, cadastral_nr);

                var price      = new LandBasePrice();
                var calculator = new LandComissionCalculator();

                Prices.GetLocationLand(land, cadastral_nr);
                Prices.GetInitialPrice(land, price);
                Prices.GetComission(land, calculator, price);
                Prices.GetPrice(land, calculator, price);
            }
        }