コード例 #1
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);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string estate;
            int    cad_nr;
            double sqm;
            string loc, cond, answer;
            int    k = 0;

            Console.WriteLine("Welcome to our Real Estate Agency!");
            while (k == 0)
            {
                Console.WriteLine("What are you looking for?(House/Flat/Studio/Land)");
                estate = Console.ReadLine();
                Console.WriteLine(" ");

                if (estate == "House")
                {
                    var initialPrice = new HouseInitPrice();
                    var calculator   = new HouseComissionCalculator();
                    Console.WriteLine("How many square meters?");
                    sqm = double.Parse(Console.ReadLine());
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose a location (center/somewhere ok/suburbs)");
                    loc = Console.ReadLine();
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose the house condition(new/medium/old)");
                    cond = Console.ReadLine();
                    Console.WriteLine(" ");

                    House house = new House(sqm, loc, cond);
                    //Console.WriteLine(house.sm);
                    // Console.WriteLine("(Price withouth fee:" + house.Get_price_fromLandlord(initialPrice.Get_price_fromLandlord(house)) + " , the poundage:" + house.Get_poundage(calculator.Get_poundage(house, initialPrice.Get_price_fromLandlord(house))) + ")" + "The total price of this house is: " + house.Get_price(calculator.Get_price(house, initialPrice.Get_price_fromLandlord(house))));
                    RealEstatePrices.GetInitialPriceFrom(house, initialPrice);
                    RealEstatePrices.GetComissionFrom(house, calculator, initialPrice);
                    RealEstatePrices.GetPriceFrom(house, calculator, initialPrice);
                    RealEstatePrices.GetLocationFrom(loc, house);
                    //TestGoodPrice(house);
                }
                else if (estate == "Flat")
                {
                    var initialPrice = new FlatInitPrice();
                    var calculator   = new FlatComissionCalculator();
                    Console.WriteLine("How many square meters?");
                    sqm = double.Parse(Console.ReadLine());
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose a location (center/somewhere ok/suburbs)");
                    loc = Console.ReadLine();
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose the house condition(new/medium/old)");
                    cond = Console.ReadLine();
                    Console.WriteLine(" ");

                    Flat flat = new Flat(sqm, loc, cond);
                    RealEstatePrices.GetInitialPriceFrom(flat, initialPrice);
                    RealEstatePrices.GetComissionFrom(flat, calculator, initialPrice);
                    RealEstatePrices.GetPriceFrom(flat, calculator, initialPrice);
                    //Console.WriteLine("(Price withouth fee:" + flat.Get_price_fromLandlord(initialPrice.Get_price_fromLandlord(flat)) + " , the poundage:" + flat.Get_poundage(calculator.Get_poundage(flat, initialPrice.Get_price_fromLandlord(flat))) + ")" + "The total price of this house is: " + flat.Get_price(calculator.Get_price(flat, initialPrice.Get_price_fromLandlord(flat))));
                    RealEstatePrices.GetLocationFrom(loc, flat);
                }
                else if (estate == "Studio")
                {
                    var initialPrice = new StudioInitPrice();
                    var calculator   = new StudioComissionCalculator();
                    Console.WriteLine("How many square meters?");
                    sqm = double.Parse(Console.ReadLine());
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose a location (center/somewhere ok/suburbs)");
                    loc = Console.ReadLine();
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose the house condition(new/medium/old)");
                    cond = Console.ReadLine();

                    Studio studio = new Studio(sqm, loc, cond);
                    RealEstatePrices.GetInitialPriceFrom(studio, initialPrice);
                    RealEstatePrices.GetComissionFrom(studio, calculator, initialPrice);
                    RealEstatePrices.GetPriceFrom(studio, calculator, initialPrice);
                    // Console.WriteLine("(Price withouth fee:" + studio.Get_price_fromLandlord(initialPrice.Get_price_fromLandlord(studio)) + " , the poundage:" + studio.Get_poundage(calculator.Get_poundage(studio,initialPrice.Get_price_fromLandlord(studio))) + ")" + "The total price of this house is: " + studio.Get_price(calculator.Get_price(studio, initialPrice.Get_price_fromLandlord(studio))));
                    RealEstatePrices.GetLocationFrom(loc, studio);
                }

                else if (estate == "Land")
                {
                    var initialPrice = new LandInitPrice();
                    var calculator   = new LandComissionCalculator();

                    Console.WriteLine("How many square meters?");
                    sqm = double.Parse(Console.ReadLine());
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose a cadastral number (543345/23214/61321)");
                    cad_nr = int.Parse(Console.ReadLine());
                    Console.WriteLine(" ");
                    Console.WriteLine("Choose the usage(intravilan/extravilan)");
                    cond = Console.ReadLine();
                    Console.WriteLine(" ");

                    UrbanLand land = new UrbanLand(sqm, cad_nr, cond);
                    RealEstatePrices.GetInitialPriceFrom(land, initialPrice);
                    RealEstatePrices.GetComissionFrom(land, calculator, initialPrice);
                    RealEstatePrices.GetPriceFrom(land, calculator, initialPrice);
                    RealEstatePrices.GetLocationLandFrom(cad_nr, land);
                    // Console.WriteLine("(Price withouth fee:" + land.Get_price_fromLandlord(initialPrice.Get_price_fromLandlord(land)) + " , the poundage:" + land.Get_poundage(calculator.Get_poundage(land, initialPrice.Get_price_fromLandlord(land))) + ")" + "The total price of this house is: " + land.Get_price(calculator.Get_price(land, initialPrice.Get_price_fromLandlord(land))));
                }

                Console.WriteLine(" ");
                Console.WriteLine("Are you searching for something else?(yes/no)");
                answer = Console.ReadLine();
                if (answer != "yes")
                {
                    k = 1;
                }
            }
            Console.WriteLine(" ");
            Console.WriteLine("Thank you for choosing us! We hope you found what you were looking for! Have a good day!");
        }