コード例 #1
0
ファイル: TelaInicial.cs プロジェクト: GSeima/Cursos
        public override string ToString()
        {
            Console.WriteLine("Enter rental data: \n");

            Console.Write("Car Model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy HH:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy HH:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE: ");

            Console.Write(carRental.Invoice);

            return("");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: karolinagb/estudos-c-sharp
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data:");
            Console.Write("Car model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm): ");

            //UTILIZANDO ParseExact para escolher como a variavel guardará a data:
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double pricePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double pricePerDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            //Instanciando o aluguel do carro:
            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            /*Estou incluindo a implementaçãod a classe concreta BrazilTaxService e a mesma casa com o objeto ITaxService
             * no construtor por meio de Upcasting já que o BrazilTaxService é subtipo de ITaxService*/
            RentalService rentalService = new RentalService(pricePerHour, pricePerDay, new BrazilTaxService());

            //A operação abaixo deve instanciar o meu invoice associado ao meu carRental
            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("Invoice:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car model: ");
            string carName = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy HH:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy HH:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double priceHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double priceDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(carName));

            RentalService rentalService = new RentalService(priceHour, priceDay, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #4
0
        public static void Executar()
        {
            Console.WriteLine("Insira os dados do aluguel: ");

            Console.Write("Modelo do carro: ");
            string model = Console.ReadLine();

            Console.Write("Inicio (dd/MM/yyyy hh:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Retorno (dd/MM/yyyy hh:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Insira preço por hora: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Insira o preço por dia: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("Fatura final: ");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Igor-IS/LocadoraDeCarros
        static void Main(string[] args)
        {
            string model    = GetModelVehicle();
            var    carModel = new Vehicle(model);

            DateTime start  = GetStartDate();
            DateTime finish = GetFinishDate();

            try
            {
                var    carRental     = new CarRental(start, finish, carModel);
                double hour          = GetPricePerHour();
                double day           = GetPricePerDay();
                var    rentalService = new RentalService(hour, day, new BrazilTaxService());
                rentalService.ProcessInvoice(carRental);
                Console.WriteLine("Invoice: \n" + carRental.Invoice);
            }
            catch (FormatException error)
            {
                Console.WriteLine("Error" + error.Message);
            }
            catch (Exception error)
            {
                Console.WriteLine("Unexpected error" + error.Message);
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Inmforme os dados da locação");
            Console.Write("Modelo do carro: ");
            string model = Console.ReadLine();

            Console.Write("Check-out (dd/mm/aaaa HH:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Check-in (dd/MM/aaaa HH:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Informe o preço por hora: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Informe o preço da diária: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental     carRental     = new CarRental(start, finish, new Vehicle(model));
            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine();
            Console.WriteLine("FATURA:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (RentalService rentalService = new RentalService())
            {
                DialogResult dr = MessageBox.Show("Güncellemek istediğinize emin misiniz?", "Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dr == DialogResult.Yes)
                {
                    RentalDTO rental = new RentalDTO
                    {
                        RentalId   = (int)lstBoxRental.SelectedValue,
                        CustomerId = (int)cmbCustomer.SelectedValue,
                        MovieId    = (int)cmbMovieName.SelectedValue,
                        BeginDate  = dtpBegin.Value,
                        EndDate    = dtpBegin.Value,
                        TotalPrice = Convert.ToDecimal(txtPrice.Text),

                        CreatedBy      = 2,
                        RecordStatusId = Convert.ToByte(cbRecordStatus.SelectedValue)
                    };
                    var result = rentalService.Update(rental);
                    lstBoxRental.DataSource = rentalService.List();
                    if (result)
                    {
                        MessageBox.Show("Güncelleme başarılı", "Durum", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Güncelleme sırasında bir hata oluştu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #8
0
        /*
         * Regras
         * Valor por hora de até 12 horas
         * Se, > 12 horas... alocação vira valor diário
         * Imoposto
         * 20% até 100 reais
         * 15% > 100 reais
         *
         * Programa
         * Dados de locação
         * Modelo do carro
         * instante inicial
         * instante final
         * valor por hora
         * valor diário de locação
         *
         * Resultado
         * Notas de pagamentos
         * valor da locação
         * valor do imposto
         * valor do pagamento total
         *
         */

        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car Model : ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm) : ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm) : ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            CarRental carrental = new CarRental(start, finish, new Vehicle(model));

            Console.Write("Enter price per hour : ");
            double priceperhour = double.Parse(Console.ReadLine());

            Console.Write("Enter price per day : ");
            double priceperday = double.Parse(Console.ReadLine());

            // Informar a interface para o construtor
            // Instancia o serviço de aluguem com a dependência que quer, o objeto define qual função vai ser usada na
            // interface tac
            // Parte da injeção de cotrole e inverção de dependência. Passa a dependência como parâmetro,
            // logo é possível ter uma interface que aponta para várias dependências diferentes. No caso
            // Desse exemplo, as dependências são as taxas de cada país. Com isso da para apontar mais paises para a
            // mesma interface mudando apenas a forma de passa a dependência desse construtor.
            RentalService rentalservice = new RentalService(priceperhour, priceperday, new BrazilTaxService());

            rentalservice.ProcessInvoice(carrental);

            Console.WriteLine();
            Console.WriteLine("INVOICE");
            Console.WriteLine(carrental.Invoice);
        }
コード例 #9
0
        public JsonResult AddJobRequest(MarketJobModel model)
        {
            var user    = User.Identity.Name;
            var files   = Request.Files;
            var login   = AccountService.GetLoginByEmail(user);
            var request = PropertyService.GetPropertyRequestById(model.RequestId);

            if (request == null)
            {
                return(Json(new { Success = false, Message = "No record found!" }));
            }
            if (request.RequestStatusId == (int)JobRequestStatus.Accepted)
            {
                return(Json(new { Success = true, Message = "Job Already Created !!", Posted = false }));
            }
            //request.RequestStatusId = (int)JobRequestStatus.Accepted;
            //request.IsUpdated = true;
            if (ModelState.IsValid)
            {
                var result = RentalService.AddTenantJobRequest(model, login, Request.Files);
                if (result.IsSuccess)
                {
                    return(Json(new { Success = true, Message = "Job Created And Updated", Posted = true }));
                }
                else
                {
                    return(Json(new { Success = false, ErrorMsg = result.ErrorMessage }));
                }
            }
            return(Json(new { Success = false, ErrorMsg = "Invalid fields" }));
        }
コード例 #10
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                string   model   = txtModel.Text;
                DateTime start   = DateTime.Parse(dateP.Text + " " + timeP.Text);
                DateTime fisnish = DateTime.Parse(dateR.Text + " " + timeR.Text);
                double   hour    = double.Parse(txtPricePerHours.Text);
                double   day     = double.Parse(txtPricePerDays.Text);

                CarRental     carRental     = new CarRental(start, fisnish, new Vehicle(model));
                RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

                rentalService.ProcessInvoice(carRental);


                LabelResult.Text = carRental.Invoice.ToString();
                listaObjRental.Add(new CarRental(start, fisnish, new Vehicle(model)));
            }

            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro, revise os campos");
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car Model: ");
            string carModel = Console.ReadLine();

            Console.Write("PickUp (dd/mm/yyyy  hh:mm): ");
            DateTime carStart = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.CurrentUICulture);

            Console.Write("Return (dd/mm/yyyy  hh:mm): ");
            DateTime carReturn = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(carStart, carReturn, new Vehicle(carModel));

            Console.Write("Enter price per hour: ");
            double pricePerHour = double.Parse(Console.ReadLine());

            Console.Write("Enter per day: ");
            double pricePerDay = double.Parse(Console.ReadLine());

            RentalService rentalService = new RentalService(pricePerHour, pricePerDay, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine();
            Console.WriteLine("Invoice: ");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #12
0
        public ActionResult AdvanceSearchResult(string sortOrder, string currentFilter, int?page)
        {
            var user      = User.Identity.Name;
            var login     = AccountService.GetLoginByEmail(user);
            var dbContext = db.RentalListing;
            var roles     = AccountService.GetUserRolesbyEmail(User.Identity.Name);
            var isTenant  = roles.Contains(5);
            var tenant    = TenantService.GetTenantByEmail(User.Identity.Name);

            GetPropertyTypes();
            IQueryable <RentalListingModel> allRentalProperties = GetAllRentalProperties(sortOrder, isTenant);
            RentalAdvancedSearchViewModel   advancedSearch      = InitialiazeSuburbListAndPropertyType();
            string newFilter = CreateFilterForPaging(currentFilter, advancedSearch);

            ViewBag.SearchCount = 1;
            IQueryable <RentalListingModel> RentalProperties = ConfigureSorting(sortOrder, ref allRentalProperties);

            allRentalProperties = GetFilteredRentalProperties(allRentalProperties, advancedSearch);

            if (allRentalProperties.Count() == 0)
            {
                ViewBag.SearchCount   = 0;
                ViewBag.CurrentFilter = "";
                allRentalProperties   = RentalProperties;
            }
            allRentalProperties.ToList().ForEach(x => x.WatchListText = RentalService.GetWatchListStatus(x.Id, login.Id));
            TempData["CurrentLink"] = "RentallListing";
            CreatePaging(page, allRentalProperties, advancedSearch, newFilter);
            advancedSearch.IsUserTenant            = isTenant;
            advancedSearch.IsTenantProfileComplete = tenant?.IsCompletedPersonalProfile ?? false;
            return(View(advancedSearch));
        }
コード例 #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data: ");
            Console.Write("Car model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm): ");
            //forma para pegar data exata e tratando o valor lançado pelo usuario
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            //instanciando o objeto
            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day);

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter your rental data");
            Console.Write("Car Model: ");
            string carModel = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy  hh:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy  hh:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double priceHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double priceDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental c1 = new CarRental()
            {
                Vehicle = new Vehicle {
                    Model = carModel
                }, Start = start, Finish = finish
            };
            // CarRental c1 = new CarRental(start, finish, new Vehicle(carModel));

            // RentalService rental = new RentalService() { PricePerHour = priceHour, PricePerDay = priceDay, };
            RentalService rental = new RentalService(priceHour, priceDay, new BrazilTaxService());


            rental.ProcessInvoice(c1);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(c1.Invoice);
        }
コード例 #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data:");
            Console.WriteLine("Car Model:  ");
            string model = Console.ReadLine();

            Console.WriteLine("Pickup (dd/MM/yyyy hh:mm) :   ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.WriteLine("Return  (dd/MM/yyyy hh:mm) :   ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.WriteLine("Enter price per Hour:");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.WriteLine("Enter price per Day:");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental     carRental     = new CarRental(start, finish, new Vehicle(model));
            RentalService rentalService = new RentalService(hour, day, new BrasiTaxService());

            rentalService.ProcessInvoice(carRental);
            Console.WriteLine(carRental);

            Console.WriteLine("Invoice");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Digite  rental data");
            Console.Write("Car model");
            string model = Console.ReadLine();

            Console.Write("Digite a data de retirada (dd/MM/YYYY hh:mm) ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Digite a data de retorno (dd/MM/YYYY hh:mm) ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Price per hour :");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Price per day :");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            // Passando a dependecia BrasilTaxService == ITaxService do contructor do RentalService por meio
            // De Upcasting pois BrazilTaxService e um subtipo
            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #17
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car Model: ");
            string carModel = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm): ");
            DateTime pickup = DateTime.Parse(Console.ReadLine());

            Console.Write("Return (dd/MM/yyyy hh:mm): ");
            DateTime finish = DateTime.Parse(Console.ReadLine());

            Console.Write("Enter price per hour: ");
            double pricePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per Day: ");
            double pricePerDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental     carRental     = new CarRental(pickup, finish, new Vehicle(carModel));
            RentalService rentalService = new RentalService(pricePerHour, pricePerDay, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine(carRental.Invoice);
        }
コード例 #18
0
        }//end of Post method

        /// <summary>
        /// Get Rentals from Database based on the parameter UserId
        /// </summary>
        /// <param name="userID">The id of the User the Rental Objects are associated with</param>
        /// <returns></returns>
        public IHttpActionResult Get(int userID)
        {
            RentalService rentalService = CreateRentalService();
            var           rentalsbyID   = rentalService.GetRentalByUserID(userID);

            return(Ok(rentalsbyID));
        }
コード例 #19
0
        private void EditRentalForm_Load(object sender, EventArgs e)
        {
            using (CustomerService customerService = new CustomerService())
            {
                cmbCustomer.DataSource    = customerService.List();
                cmbCustomer.DisplayMember = "FullName";
                cmbCustomer.ValueMember   = "CustomerId";
            }

            using (MovieService movieService = new MovieService())
            {
                cmbMovieName.DataSource    = movieService.List();
                cmbMovieName.DisplayMember = "MovieName";
                cmbMovieName.ValueMember   = "MovieId";
            }

            using (RentalService movieService = new RentalService())
            {
                lstBoxRental.DataSource    = movieService.List();
                lstBoxRental.DisplayMember = "Display";
                lstBoxRental.ValueMember   = "RentalId";
            }

            using (DefinitionService definitionService = new DefinitionService())
            {
                cbRecordStatus.DataSource    = definitionService.GetRecordStatus();
                cbRecordStatus.DisplayMember = "RecordStatusName";
                cbRecordStatus.ValueMember   = "RecordStatusId";
            }
        }
コード例 #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Dados do Aluguel");
            Console.Write("Modelo do Carro: ");
            string model = Console.ReadLine();

            Console.Write("Entrada (dd/MM/yyyy dd:mm): ");
            DateTime dateStart = DateTime.ParseExact(Console.ReadLine(),
                                                     "dd/MM/yyyy hh:mm", CultureInfo.InstalledUICulture);

            Console.Write("Saída (dd/MM/yyyy dd:mm): ");
            DateTime dateFinish = DateTime.ParseExact(Console.ReadLine(),
                                                      "dd/MM/yyyy hh:mm", CultureInfo.InstalledUICulture);

            Console.Write("Digite o valor por hora (R$): ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Digite o valor por dia (R$): ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            //create obj_Rental
            CarRental carRental = new CarRental(dateStart,
                                                dateFinish,
                                                new Vehicle(model));

            //Calculate RENTAL - by DAY or HOUR
            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE: ");
            Console.WriteLine(carRental.Invoice);

            Console.ReadKey();
        }
コード例 #21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Entre com os dados do aluguel");
            Console.Write("Modelo do carro: ");
            string model = Console.ReadLine();

            Console.Write("Retirada (dd/MM/yyyy HH:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Devolução (dd/MM/yyyy HH:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Preço por hora? ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Preço por dia? ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("Fatura:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #22
0
        static void Main(string[] args)
        {
            //SOLUÇÃO COM INTERFACE: Ver a interface ITaxService e a classe específica da interface BrazilTaxService
            Console.WriteLine("Enter rental data");
            Console.Write("Car model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:MM): ");
            DateTime pickup = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Rentur (dd/MM/yyyy hh:MM): ");
            DateTime _return = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double pricePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double pricePerDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(pickup, _return, new Vehicle(model));

            RentalService rentalService = new RentalService(pricePerHour, pricePerDay, new BrazilTaxService()); //Agora é necessário declarar um Serviço do tipo RentalService e Incluir um terceiro parâmetro com o tipo de dependência que será utilizado sendo que nesse caso é a classe comcreta BrazilTaxService() que casará com o terceiro parâmetro do construtor da classe RentalService por meio de UpCasting.

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data:");
            Console.Write("Car model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:MM): ");
            DateTime start = DateTime.Parse(Console.ReadLine());

            Console.Write("Return (dd/MM/yyyy hh:MM): ");
            DateTime finish = DateTime.Parse(Console.ReadLine());


            Console.Write("Enter price per hour: ");
            double hour = double.Parse(Console.ReadLine());

            Console.Write("Enter price per day: ");
            double day = double.Parse(Console.ReadLine());

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.processInvoice(carRental);

            Console.WriteLine("Invoice: ");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #24
0
        public static void aluguelCarro()
        {
            Console.WriteLine("Enter rental data: ");  // Ente com os dados do aluguel
            Console.Write("Car Model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm)");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm)");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: "); // Entrar com Preco por hora.
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: "); // Entrar com Preco por dia.
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);


            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessIvoice(carRental);


            Console.WriteLine("Invoice: ");
            Console.WriteLine(carRental.Invoice);
            Console.WriteLine("<<<<--------------------------->>>")
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: Maxel-Uds/Curso-C-Sharp
        static void Main(string[] args)
        {
            Console.WriteLine("Entre com os dados da locação:");
            Console.Write("Modelo do carro: ");
            string model = Console.ReadLine();

            Console.Write("Retirada (dd/MM/yyyy hh:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Entrega (DD/MM/AAAA HH:MM): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Valor por hora: ");
            double valuePerHour = double.Parse(Console.ReadLine());

            Console.Write("Valor por dia: ");
            double valuePerDay = double.Parse(Console.ReadLine());

            CarRental     rental        = new CarRental(start, finish, new CarModel(model));
            RentalService rentalService = new RentalService(valuePerHour, valuePerDay, new BrazilTaxService());

            rentalService.ProcessInvoice(rental);

            Console.WriteLine();
            Console.WriteLine(rental.Invoice);
        }
コード例 #26
0
        static void Main(string[] args)
        {
            string   model;
            DateTime start, finish;
            double   dayP, hourP;

            CarRental     carRental;
            RentalService rentalService;

            Console.WriteLine("Enter rental data: ");
            Console.Write("Car Model: ");
            model = Console.ReadLine();
            Console.Write("Pickup (dd/mm/yyyy hh:mm): ");
            start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy hh:mm", CultureInfo.InvariantCulture);
            Console.Write("Return (dd/mm/yyyy hh:mm): ");
            finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            carRental = new CarRental(start, finish, new Vehicle(model));

            Console.Write("Enter price per hour: ");
            hourP = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
            Console.Write("Enter price per day: ");
            dayP = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            rentalService = new RentalService(hourP, dayP, new BrazilTaxService());
            rentalService.ProcessInvoice(carRental);
            Console.WriteLine("INVOICE: ");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car model: ");
            string carModel = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm) : ");
            DateTime pickupDate = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm) : ");
            DateTime returnDate = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double pricePerHour = double.Parse(Console.ReadLine());

            Console.Write("Enter price per day: ");
            double pricePerDay = double.Parse(Console.ReadLine());

            CarRental carRental = new CarRental(pickupDate, returnDate, new Vehicle(carModel));

            RentalService rentalService = new RentalService(pricePerHour, pricePerDay, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE: ");
            Console.WriteLine($"{carRental.Invoice}");



            Console.ReadKey();
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: Guga-Dev10/C-Sharp
        static void Main(string[] args)
        {
            // Solução sem o uso de interface

            Console.WriteLine("Enter rental data:");
            Console.Write("\nCar Model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (MM/dd/yyyy HH:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (MM/dd/yyyy HH:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            RentalService rentalService = new RentalService(hour, day);

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter rental data");
            Console.Write("Car model: ");
            string model = Console.ReadLine();

            Console.Write("Pickup (dd/MM/yyyy hh:mm): ");
            DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Return (dd/MM/yyyy hh:mm): ");
            DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Enter price per hour: ");
            double hour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter price per day: ");
            double day = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            CarRental carRental = new CarRental(start, finish, new Vehicle(model));

            /* Implementação SEM interface
             * RentalService rentalService = new RentalService(hour, day);
             */
            //Implementação COM interface!
            RentalService rentalService = new RentalService(hour, day, new BrazilTaxService());

            rentalService.ProcessInvoice(carRental);

            Console.WriteLine("INVOICE:");
            Console.WriteLine(carRental.Invoice);
        }
コード例 #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("Entre com os dado do aluguel:");
            Console.Write("Modelo do carro: ");
            string modelo = Console.ReadLine();

            Console.Write("Retirada (DD/MM/AAAA HH:MM): ");
            DateTime retirada = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Entrega (DD/MM/AAAA HH:MM): ");
            DateTime entrega = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            Console.Write("Preço por hora: R$");
            double precoHora = double.Parse(Console.ReadLine());

            Console.Write("Preço por dia: R$");
            double precoDia = double.Parse(Console.ReadLine());

            CarRental cr = new CarRental(retirada, entrega, new Vehicle(modelo));

            RentalService rs = new RentalService(precoHora, precoDia);

            rs.ProcessInvoice(cr);

            Console.WriteLine("INVOICE:");

            Console.WriteLine(cr.Invoice);
        }