Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions