From the course: Jakarta EE: Building Your First Application

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Complete business logic in Jakarta RESTful resource

Complete business logic in Jakarta RESTful resource

From the course: Jakarta EE: Building Your First Application

Complete business logic in Jakarta RESTful resource

- [Instructor] Let's start from where we left our code that generates the price change value. And now for the business rule, I get the day of the week. So I'll type int dayOfWeek by saying now.get Calendar.DAY_OF_WEEK, which would be 1 for Sunday and 7 for Saturday for a week starting from Sunday. And then I do a switch case of the day of the week. Case 2 and 3 here is Monday and Tuesday. So we have the price increasing by an amount between $1 to $5. So I create a random integer with the least value of 1, inclusive, and an upper bound of 6, exclusive. Case 4, which is Wednesday, we have the price reduced by an amount between $1 to $3 and create a random number like this. But see here that I'm making it a negative value by multiplying it by -1. Case 5 and 6, Thursdays and Fridays, the price increases by $1 to $2, and here's the random number for that. And finally, on Sunday and Saturday, the price is reduced by $1…

Contents