All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.pdx.cs.joy.di.Book Maven / Gradle / Ivy

The newest version!
package edu.pdx.cs.joy.di;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;

/**
 * A book in a book store
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class Book
{
    private String title;

    private String author;

    private double price;

    public Book() {

    }
    
    public Book( String title, String author, double price )
    {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    public String getAuthor()
    {
        return author;
    }

    public String getTitle()
    {
        return title;
    }

    public double getPrice()
    {
        return price;
    }

    @Override
    public String toString()
    {
        return this.title;
    }

    @Override
    public boolean equals( Object o )
    {
        if ( this == o ) return true;
        if ( o == null || getClass() != o.getClass() ) return false;

        Book book = (Book) o;

        if ( author != null ? !author.equals( book.author ) : book.author != null ) return false;
        if ( title != null ? !title.equals( book.title ) : book.title != null ) return false;

        return true;
    }

    @Override
    public int hashCode()
    {
        int result = title != null ? title.hashCode() : 0;
        result = 31 * result + (author != null ? author.hashCode() : 0);
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy