001package edu.pdx.cs410J.di;
002
003import jakarta.xml.bind.annotation.XmlAccessType;
004import jakarta.xml.bind.annotation.XmlAccessorType;
005
006/**
007 * A book in a book store
008 */
009@XmlAccessorType(XmlAccessType.FIELD)
010public class Book
011{
012    private String title;
013
014    private String author;
015
016    private double price;
017
018    public Book() {
019
020    }
021    
022    public Book( String title, String author, double price )
023    {
024        this.title = title;
025        this.author = author;
026        this.price = price;
027    }
028
029    public String getAuthor()
030    {
031        return author;
032    }
033
034    public String getTitle()
035    {
036        return title;
037    }
038
039    public double getPrice()
040    {
041        return price;
042    }
043
044    @Override
045    public String toString()
046    {
047        return this.title;
048    }
049
050    @Override
051    public boolean equals( Object o )
052    {
053        if ( this == o ) return true;
054        if ( o == null || getClass() != o.getClass() ) return false;
055
056        Book book = (Book) o;
057
058        if ( author != null ? !author.equals( book.author ) : book.author != null ) return false;
059        if ( title != null ? !title.equals( book.title ) : book.title != null ) return false;
060
061        return true;
062    }
063
064    @Override
065    public int hashCode()
066    {
067        int result = title != null ? title.hashCode() : 0;
068        result = 31 * result + (author != null ? author.hashCode() : 0);
069        return result;
070    }
071}