package engine.gameobject.weapon.upgradable.firingrate;

import java.util.Optional;
import engine.gameobject.weapon.Upgrade;

public class FiringRateUpgrade implements FiringRate {
    
    private double increment;
    private Optional<FiringRate> decorated;

    public FiringRateUpgrade() {
        increment = 0;
    }
    
    public FiringRateUpgrade (double increment) {
        this.increment = increment;
    }

    @Override
    public double getRate () {
        return decorated.map(FiringRate::getRate).orElse(increment);
    }
    
    @Override
    public Class<? extends Upgrade> getType () {
        return FiringRate.class;
    }

    @Override
    public void setDecorated (Upgrade decorated) {
        this.decorated = Optional.of((FiringRate) decorated);
    }

    @Override
    public void setDefault () {
        this.decorated = Optional.of(new FiringRateUpgrade(0));
    }

}

@@ -283,24 +283,52 @@
 Upgrade() %7B%0A
+        setNullDecorated();%0A
         incr
@@ -338,16 +338,16 @@
 nt = 0;%0A
-
     %7D%0A  
@@ -395,24 +395,52 @@
 ncrement) %7B%0A
+        setNullDecorated();%0A
         this
@@ -464,24 +464,152 @@
 ement;%0A    %7D
+%0A    %0A    private void  setNullDecorated() %7B%0A        FiringRate nullVal = null;%0A        decorated = Optional.of(nullVal); %0A    %7D
 %0A%0A    @Overr

add null decorated to firing rate