I have a parent class in which i have a final static int which i need to shadow in a child class. In the parent class i use a method "print", which i override in my child class. If i use this code, the method print will use the MINIMUMPRIJS from my parent class. How can i make it use the MINIMUMPRIJS from my childclass?
In my taskdescription it says about the class "reis":
- Make sure the price is at least 5 euros. Create a variable for this and make sure this minimumprice is always guaranteed.
- 1 constructor with 1 paramter (destination)
- 1 constructor with paramters (destiantion, price)
about the class "vliegtuigreis"
- In here the minimumprice is 25 euros. Do what is needed.
- 1 constructor with just 1 paramater (destination)
- 1 constructor with paramaters (destination, price, and flightnumber)
public abstract class Reis {
public final static int MINIMUMPRIJS = 5;
public void setPrijs(double prijs) {
if (prijs >= getMINIMUMPRIJS()) {
this.prijs = prijs;
}else{
this.prijs = MINIMUMPRIJS;
}
}
public void print(){
System.out.printf("Reis met bestemming %s kost %,.2f euro. %n", bestemming, prijs);
}
}
public class VliegtuigReis extends Reis {
private final static int MINIMUMPRIJS = 25;
public void print(){
super.print();
System.out.println("Vluchtnr " + vluchtnummer);
}
}