Can I use the strategy pattern to implement the following logic: So, imagine the tuition fee is calculated based on the overall student performance, for example if the student has an overall average mark more than 70, his tuition fee will be 70% less. And so on.. if average mark is 50 than 50% discount, in other cases no discount. So there are different strategies to calculate discount that vary depending on the average mark. How can I implement this in Java code? I suppose that there will be Student class that will have method to calculate the average mark, interface TuitionFeeCalculator and three strategies: 70persentDiscount,50%discount and noDiscount implementing TuitionFeeCalculator.
Aucun commentaire:
Enregistrer un commentaire