cz.muni.fi.pb138.jizdenky.service.pojo.FirstMinuteDiscount.java Source code

Java tutorial

Introduction

Here is the source code for cz.muni.fi.pb138.jizdenky.service.pojo.FirstMinuteDiscount.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.muni.fi.pb138.jizdenky.service.pojo;

import java.util.Date;
import org.joda.time.LocalDate;

/**
 *
 * @author Mito
 */
public class FirstMinuteDiscount extends AbstractFirstMinuteDiscount {

    private final int daysInAdvance;

    public FirstMinuteDiscount(int daysInAdvance, int discountValue, String name) {
        super(discountValue, name);
        this.daysInAdvance = daysInAdvance;
    }

    @Override
    public boolean isApplicable(LocalDate dayOfOrder) {
        return dayOfOrder.minusDays(daysInAdvance).isAfter(LocalDate.now());
    }

}