Ovn1/Book
2024-04-07 20:55:20 +02:00

30 lines
675 B
Plaintext

public class Book extends Item implements PriceableWithVAT6{
//Variabler
private final String author;
private final double price;
private final boolean bound;
//Konstruktior
public Book (String name, String author, double price, boolean bound){
super(name);
this.author = author;
this.price = price;
this.bound = bound;
}
//Metoder
public double getPrice(){
//Om boken är inbunden så ska pricet öka med 30%
if (bound) {
return this.price * 1.3;
} else {
return this.price;
}
}
public String toString(){
return this.bound + ", "+ getPrice() + ", " + super.getName() + ", " + this.author ;
}
}