示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("**********************************************Real Estate Calculator**********************************************\n");
            //Console.WriteLine("");
            Console.Write("The price in euro for the real estate is: ");

            priceRealEstate = Convert.ToDecimal(Console.ReadLine());

            Console.Write("The zone is (central, periphery): ");
            answer = (Console.ReadLine()).ToLower();
            switch (answer)
            {
            case "central":
                zone = answer; break;

            case "periphery":
                zone = answer; break;

            default:
                Console.WriteLine("Invalid value!");
                break;
            }


            IDisplayMonitor dsp = new DisplayMonitor();

            Console.WriteLine("Choose for what type of real estate you need to calculate the commission (single room, apartment, house, parcel): ");
            realEstate = Console.ReadLine().ToLower();
            switch (realEstate)
            {
            case "single room":
                Console.Write("The address is: ");
                address = Console.ReadLine();

                FeeCalculator singleRoomCalculator = new SingleRoomFeeCalculator();
                IRealEstate   room = new SingleRoom(priceRealEstate, zone, address);
                dsp.Message(room, singleRoomCalculator);

                break;

            case "apartment":
                Console.Write("The address is: ");
                address = Console.ReadLine();

                var         apartmentCalculator = new ApartmentFeeCalculator();
                IRealEstate apartment           = new Apartment(priceRealEstate, zone, address);
                dsp.Message(apartment, apartmentCalculator);
                break;

            case "house":
                Console.Write("The address is: ");
                address = Console.ReadLine();

                IRealEstate house           = new House(priceRealEstate, zone, address);
                var         houseCalculator = new HouseFeeCalculator();
                dsp.Message(house, houseCalculator);
                break;

            case "parcel":
                Console.Write("The cadastral number is: ");
                address = Console.ReadLine();

                var         parcelCalculator = new ParcelFeeCalculator();
                IRealEstate parcel           = new Parcel(priceRealEstate, zone, address);
                dsp.Message(parcel, parcelCalculator);

                TestParcel();
                break;

            default:
                Console.WriteLine("You must to choose one of the single room, apartment, hose or parcel!");
                break;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Choose 1 if you want to calculate the commission for the real estate give by you, or 2 for calculate commission for the real estate from data base!");

            val = Console.ReadLine();
            switch (val)
            {
            case "1":
                Console.Write("Choose for what type of real estate you need to calculate the commission (single room, apartment, house): ");
                realEstate = Console.ReadLine();
                switch (realEstate)
                {
                case "single room":
                    SingleRoom room = new SingleRoom();
                    Console.Write("The price for a single room is: ");
                    priceRealEstate       = Console.ReadLine();
                    priceRealEstateDouble = Convert.ToDouble(priceRealEstate);
                    Console.Write("Commission for single room  with price " + priceRealEstateDouble + " is: ");
                    Console.WriteLine(room.CalculationCommissionn(priceRealEstateDouble));

                    break;

                case "apartment":
                    Apartment apartment = new Apartment();
                    Console.Write("The price for an apartment is: ");
                    priceRealEstate       = Console.ReadLine();
                    priceRealEstateDouble = Convert.ToDouble(priceRealEstate);
                    Console.Write("Commission for apratment with price " + priceRealEstateDouble + " is: ");
                    Console.WriteLine(apartment.CalculationCommissionn(priceRealEstateDouble));

                    break;

                case "house":
                    House house = new House();
                    Console.Write("The price for a house is: ");
                    priceRealEstate       = Console.ReadLine();
                    priceRealEstateDouble = Convert.ToDouble(priceRealEstate);
                    Console.Write("Commission for house with price " + priceRealEstateDouble + " is: ");
                    Console.WriteLine(house.CalculationCommissionn(priceRealEstateDouble));

                    break;

                default:
                    Console.Write("You must to choose one of the single room, apartment, hose!");
                    break;
                }

                break;

            case "2":
                Console.Write("Choose for what type of real estate you need to calculate the commission (single room, apartment, house): ");
                choose = Console.ReadLine();
                switch (choose)
                {
                case "single room":
                    SingleRoom room = new SingleRoom();
                    for (int i = 0; i < singleRoomPrice.Length; i++)
                    {
                        Console.Write("Commission for single room  with price " + singleRoomPrice[i] + " is: ");
                        Console.WriteLine(room.CalculationCommissionn(singleRoomPrice[i]));
                    }
                    break;

                case "apartment":
                    Apartment apartment = new Apartment();
                    for (int i = 0; i < apartmentPrice.Length; i++)
                    {
                        Console.Write("Commission for apratment with price " + apartmentPrice[i] + " is: ");
                        Console.WriteLine(apartment.CalculationCommissionn(apartmentPrice[i]));
                    }
                    break;

                case "house":
                    House house = new House();
                    for (int i = 0; i < housePrice.Length; i++)
                    {
                        Console.Write("Commission for house with price " + housePrice[i] + " is: ");
                        Console.WriteLine(house.CalculationCommissionn(housePrice[i]));
                    }
                    break;

                default:
                    Console.Write("You must to choose one of the single room, apartment, hose!");
                    break;
                }
                break;

            default:
                Console.Write("You can choose 1 or 2!");
                break;
            }
        }