Java8-Assessment2
Part 1: eCart Basics with Stream API
- Product Creation and Initialization:
• Create a Product class with attributes like id, name, price, and rating.
• Initialize a list of products. Use Stream.of() to add products to the list
//Basic Setup Step 1: Create a Product class and make a attributes id, name, price, and rating
Step 2: create a one DataClass Here add some list like ProductList add initialize the cart list;
Step 3. create a ProductController class here add a all Operation what we need
P1Q1. • Initialize a list of products. Use Stream.of() to add products to the list
Step 1. Create a One P1Q1 Class and add main method
step 2. in controller class add a method getProductListUsingStreamOf and using Stream.of() add some product and print;
P1Q2. . Filtering Products:
- Use the filter() method to list products below a certain price.
step 1. create getProductsBelowPrice method in a controller class and here add some filter with predicate like if product. is below certain price. step 2. use a P1Q2 class call getProductsBelowPrice and pass the price and print the all value with this list.