001package edu.pdx.cs410J.di;
002
003import jakarta.xml.bind.annotation.XmlAccessType;
004import jakarta.xml.bind.annotation.XmlAccessorType;
005
006/**
007 * A class that represents a credit card
008 */
009@XmlAccessorType(XmlAccessType.FIELD)
010public class CreditCard
011{
012    private String number;
013
014    /**
015     * For marshalling
016     */
017    public CreditCard() {
018
019    }
020
021    /**
022     * Creates a credit card with the given card number
023     * @param number The card number
024     */
025    public CreditCard( String number )
026    {
027        this.number = number;
028    }
029
030
031    /**
032     * Returns the number of this credit card
033     */
034    public String getNumber()
035    {
036        return number;
037    }
038
039  @Override
040  public String toString() {
041    return "Credit card for " + this.number;
042  }
043
044  @Override
045  public boolean equals(Object o) {
046    if (this == o) return true;
047    if (o == null || getClass() != o.getClass()) return false;
048
049    CreditCard that = (CreditCard) o;
050
051    return !(number != null ? !number.equals(that.number) : that.number != null);
052
053  }
054
055  @Override
056  public int hashCode() {
057    return number != null ? number.hashCode() : 0;
058  }
059}