48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
abstract public class Recording extends Item implements PriceableWithVAT25 {
|
|
private final String artist;
|
|
private final int year;
|
|
private int condition;
|
|
private final double price;
|
|
|
|
|
|
protected Recording(String name, String artist, int year, int condition, double price) {
|
|
super(name);
|
|
this.artist = artist;
|
|
this.year = year;
|
|
this.condition = condition (condition < 0 || condition > 10) ? 0 : condition;
|
|
this.price = price;
|
|
}
|
|
|
|
//Hjälpmetoder för att få inspelningsattribut
|
|
public String getArtist() {
|
|
return this.artist;
|
|
}
|
|
|
|
public abstract String getType();
|
|
|
|
public int getCondition() {
|
|
return condition;
|
|
}
|
|
|
|
public double getPrice() {
|
|
//Inga skivor kan få ett värde under 10 kronor före moms.
|
|
if (this.price * (Double.valueOf(this.condition)/10) > 10){
|
|
return this.price * (Double.valueOf(this.condition)/10);
|
|
}else {
|
|
return 10;
|
|
}
|
|
}
|
|
|
|
public String toString(){
|
|
//return super.getName() + ", '" + this.artist + "', " + this.year + ", " + this.condition + ", " + getOriginalPrice();
|
|
return getType() + " { name =" + super.getName() + ", artist='" + this.artist + "', year=" + this.year + ", condition=" + this.condition + ", original price=" + getOriginalPrice() + ", price=" + getPrice() + ", price+vat=" + getPriceWithVAT() +" }";
|
|
}
|
|
|
|
public int getYear() {
|
|
return this.year;
|
|
}
|
|
|
|
protected double getOriginalPrice() {
|
|
return this.price;
|
|
}
|
|
} |