Hi all
This is probably a pretty basic OO question, but here goes:
I have a simple Course class, containing a course ID, course name,
course price etc.
I´m looking for a good way to implement different types of special
offers on these courses,
like "buy five courses, get 10% off" or "from September 1 to September
15, get 5% off this course".
What would be the best way to do this?
I was thinking something like
interface SpecialOffer {
double getSpecialOfferPrice(Course c); //Return new price
double getSpecialOfferSavings(Course c); //Return % saved
}
class BuyManyOffer implements SpecialOffer {
Integer buyManyLimit;
public LimitedTimeOffer(Date date) {
this. buyManyLimit = date;
}
public double getSpecialOfferPrice(Course c) {
//return something;
}
double getSpecialOfferSavings(Course c) {
return somethingElse;
}
}
class LimitedTimeOffer implements SpecialOffer {
Date offerStart;
Date offerStop;
public LimitedTimeOffer(Date dateStart, Date dateStop) {
this.offerStart = dateStart;
this.offerStop = dateStop;
}
public double getSpecialOfferPrice(Course c) {
//return something;
}
double getSpecialOfferSavings(Course c) {
return somethingElse;
}
}
But is this really the way to go?
I can create different offers, the constructor allows me to dictate
the rules for the offer to apply.
But I don´t know how I would know if the offer applies or not at a
given time.
Somehow I need to know that the customer has bought more than x number
of courses, or bought the course inside the time limit,
but if I put number of courses in the interface, it wouldn´t make
sense for the LimitedTimeOffer,
and putting the a date in there wouldn´t make sense to the
BuyManyOffer.
Any pointers?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---