javaDocedRefactoringExample.states

Class MovieState

    • Constructor Summary

      Constructors 
      Constructor and Description
      MovieState() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      float getAmountDue(int numberOfDaysRented)
      Gets the amount due for a given state.
      int getFrequentRenterPoints(int numberOfDaysRented)
      Get the frequent renter points for this movie according to the number of days it was rented.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MovieState

        public MovieState()
    • Method Detail

      • getAmountDue

        public float getAmountDue(int numberOfDaysRented)
        Gets the amount due for a given state. A template method pattern.
        Parameters:
        numberOfDaysRented -
        Pre-condition:
        numberOfDaysRented ≥ 0
        Post-condition:
        numberOfDaysRented ≤ getBaseRateThreshold() ⇒ result = getBaseRate()
        ELSE
        result = getBaseRate() + (numberOfDaysRented - getBaseRateThreshold()) * getExtraTimeRate()
      • getFrequentRenterPoints

        public int getFrequentRenterPoints(int numberOfDaysRented)
        Get the frequent renter points for this movie according to the number of days it was rented.
        Parameters:
        numberOfDaysRented - the number of days this movie was rented
        Pre-condition:
        numberOfDaysRented ≥ 0
        Post-condition:
        this instanceof NewReleasedMovieState AND numberOfDaysRented > 1 ⇒ result = 2
        ELSE
        result = 1