private void setDiscount(boolean discount, Data data) { double totalPrice = bill.getTotalPrice(); LocalDate date = data.getDate(); if ((date.equals(hollidayChristmas)) || (date.equals(hollidayIndepenanceDay)) || (date.equals(hollidayProgrammerDay))) { totalPrice *= 0.5; bill.setTotalPrice(totalPrice); discount = false; logger.info(resourceBundle.getString("economyHollidays") + bill.getTotalPrice()); bill.setHollidays( resourceBundle.getString("economyHollidays") + String.format(" %.2f ", bill.getTotalPrice())); } else { logger.info(resourceBundle.getString("noEconomy")); bill.setHollidays(resourceBundle.getString("noEconomy")); } if (discount == true) { double discountPay = bill.getTotalPrice() * 0.1; totalPrice *= 0.9; bill.setTotalPrice(totalPrice); logger.info(resourceBundle.getString("yourDiscount") + discountPay); bill.setDiscount( resourceBundle.getString("yourDiscount") + " " + String.format(" %.2f ", discountPay)); } else if (discount == false) { totalPrice *= 1; bill.setTotalPrice(totalPrice); logger.info(resourceBundle.getString("noDiscount")); bill.setDiscount(resourceBundle.getString("noDiscount")); } }
private void weekends(Data data) { LocalDate date = data.getDate(); double price = bill.getTotalPrice(); if (date.getDayOfWeek().equals(DayOfWeek.FRIDAY) || date.getDayOfWeek().equals(DayOfWeek.SATURDAY) || date.getDayOfWeek().equals(DayOfWeek.SUNDAY)) { double weekendsPay = 0.05 * bill.getTotalPrice(); price *= 1.05; bill.setTotalPrice(price); logger.info(resourceBundle.getString("payForWeekends") + weekendsPay); bill.setWeekends( resourceBundle.getString("payForWeekends") + " " + String.format(" %.2f", weekendsPay)); } }
private void check(Data data) { LocalDate date = data.getDate(); double price = bill.getTotalPrice(); if (date.getYear() > 2015 && date.getMonth().equals(Month.SEPTEMBER) && date.getDayOfMonth() < 8 && date.getDayOfWeek().equals(DayOfWeek.SATURDAY)) { price *= 1; bill.setTotalPrice(price); logger.info(resourceBundle.getString("noTips")); bill.setTips(resourceBundle.getString("noTips")); } else { double tips = 0.05 * bill.getTotalPrice(); price *= 1.05; bill.setTotalPrice(price); logger.info(resourceBundle.getString("payForTips") + tips); bill.setTips(resourceBundle.getString("payForTips") + " " + String.format(" %.2f ", tips)); } }