# Class PriceChangedEvent

java.lang.Object
com.university.bookstore.observer.PriceChangedEvent

All Implemented Interfaces:
  `MaterialEvent`

public class PriceChangedEvent extends Object implements MaterialEvent
Event that occurs when a material's price changes.

Since:
  2024-09-15
Version:
  3.0
Author:
  Navid Mohaghegh

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PriceChangedEvent(Material material, double oldPrice, double newPrice)`
  Creates a new price changed event.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String`
  `getDescription()`
  Gets a description of this event.
  `String`
  `getEventType()`
  Gets the type of this event.
  `Material`
  `getMaterial()`
  Gets the material associated with this event.
  `double`
  `getNewPrice()`
  Gets the new price.
  `double`
  `getOldPrice()`
  Gets the old price.
  `double`
  `getPriceChange()`
  Gets the price change amount.
  `double`
  `getPriceChangePercentage()`
  Gets the price change percentage.
  `long`
  `getTimestamp()`
  Gets the timestamp when this event occurred.
  `int`
  `hashCode()`
  `boolean`
  `isPriceDecrease()`
  Checks if the price decreased.
  `boolean`
  `isPriceIncrease()`
  Checks if the price increased.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### PriceChangedEvent

    public PriceChangedEvent(Material material, double oldPrice, double newPrice)
    Creates a new price changed event.
    Parameters:
      `material` - the material whose price changed
      `oldPrice` - the previous price
      `newPrice` - the new price
    Throws:
      `IllegalArgumentException` - if material is null or prices are negative

- ## Method Details

  - ### getMaterial

    public Material getMaterial()
    Description copied from interface: `MaterialEvent`
    Gets the material associated with this event.
    Specified by:
      `getMaterial` in interface `MaterialEvent`
    Returns:
      the material

  - ### getTimestamp

    public long getTimestamp()
    Description copied from interface: `MaterialEvent`
    Gets the timestamp when this event occurred.
    Specified by:
      `getTimestamp` in interface `MaterialEvent`
    Returns:
      the event timestamp in milliseconds

  - ### getEventType

    public String getEventType()
    Description copied from interface: `MaterialEvent`
    Gets the type of this event.
    Specified by:
      `getEventType` in interface `MaterialEvent`
    Returns:
      the event type

  - ### getDescription

    public String getDescription()
    Description copied from interface: `MaterialEvent`
    Gets a description of this event.
    Specified by:
      `getDescription` in interface `MaterialEvent`
    Returns:
      the event description

  - ### getOldPrice

    public double getOldPrice()
    Gets the old price.
    Returns:
      the previous price

  - ### getNewPrice

    public double getNewPrice()
    Gets the new price.
    Returns:
      the new price

  - ### getPriceChange

    public double getPriceChange()
    Gets the price change amount.
    Returns:
      the price change (new - old)

  - ### getPriceChangePercentage

    public double getPriceChangePercentage()
    Gets the price change percentage.
    Returns:
      the price change percentage

  - ### isPriceIncrease

    public boolean isPriceIncrease()
    Checks if the price increased.
    Returns:
      true if the price increased

  - ### isPriceDecrease

    public boolean isPriceDecrease()
    Checks if the price decreased.
    Returns:
      true if the price decreased

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`