Question: public int getNumberOfItemsBought ( String username ) { / / Implement the logic to count the number of items bought by the given user /

public int getNumberOfItemsBought(String username){
// Implement the logic to count the number of items bought by the given user
// using the ordersService.
}
i need logic for this aove metthod
Task 1
You are writing an endpoint that returns the total number of items bought in your online store by a given user.
Orders in your system are stored in an external service called
OrdersService 2. Your task is to:
write an endpoint in the given UsersController rass;
write a method in the given UsersService class that counts the number of items bought by the given user;
configure the UsersController and UsersService classes.
Solving this task requires from you editing the following three files. Please make sure they are all present in your final solution.
com.codility. app. AppConfiguration
com.codility. app. UsersController
com.codility. app. UsersService
Interfaces
The UsersService class declares:
a field ordersService : private ordersService ordersService
a method getNumberofItemsBought 0 : public int getNumber0fItemsBought (String username)
The Uselscontroller class declares:
a field usersservice private UsersService usersService
a method totalt temaBought in public Man
 public int getNumberOfItemsBought(String username){ // Implement the logic to count the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!