edu.pdx.cs410J.di.CreditCard Maven / Gradle / Ivy
The newest version!
package edu.pdx.cs410J.di;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
/**
* A class that represents a credit card
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class CreditCard
{
private String number;
/**
* For marshalling
*/
public CreditCard() {
}
/**
* Creates a credit card with the given card number
* @param number The card number
*/
public CreditCard( String number )
{
this.number = number;
}
/**
* Returns the number of this credit card
*/
public String getNumber()
{
return number;
}
@Override
public String toString() {
return "Credit card for " + this.number;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CreditCard that = (CreditCard) o;
return !(number != null ? !number.equals(that.number) : that.number != null);
}
@Override
public int hashCode() {
return number != null ? number.hashCode() : 0;
}
}