import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.*; @RestController public class CheckoutController { @GetMapping("/checkout") public Map checkout( @RequestParam String products, @RequestParam(required = false) String coupon) { // Parse products Map productQuantities = new HashMap<>(); for (String productEntry : products.split(",")) { String[] parts = productEntry.split(":"); productQuantities.put( parts[0], // Product ID Integer.parseInt(parts[1]) // Quantity ); } // Build result Map result = new HashMap<>(); result.put("products", productQuantities); result.put("coupon", coupon != null ? coupon : "No coupon applied"); return result; } }
top of page
Stephen Patrick

Stephen Patrick

Writer

Functional Organization Expert

More actions

Profile

Join date: Feb 2, 2024

Posts (115)

Apr 29, 20265 min
How to Prevent Clothes from Fading
We’ve all had that "oh no" moment. You buy a deep black pair of jeans or a vibrant red shirt, but after just a few washes, they look grey, dull, and old. This is called fading, and it’s the number one reason people throw away clothes they still love. The good news? Fading isn't inevitable. By changing a few simple habits in your laundry room and your closet, you can prevent clothes from fading and keep your wardrobe looking fresh for years. Why Do Clothes Fade? Before we talk about the fix,...

5
0
1
Apr 21, 20267 min
How to Remove Tough Stains from Clothes at Home: The Ultimate Professional Guide
Your wardrobe is an investment, a collection of memories, and a reflection of your personal brand. Yet, it only takes a millisecond, a stray drop of balsamic glaze, or a leaky ballpoint pen, to turn a designer piece into a "house shirt." Most people approach tough stains on clothes with a mix of panic and guesswork, often reaching for the wrong chemical and inadvertently sealing the garment’s fate. The truth is that removing stains from fabric isn't about scrubbing harder; it’s about...

25
0
2
Apr 14, 20266 min
Beyond the Squeeze: The Definitive Guide to Off-Season Storage Without Vacuum Bags
We’ve all experienced that sinking feeling: pulling a favorite cashmere sweater or a crisp linen blazer out of storage only to find it crushed, lifeless, and smelling of stale plastic. While storing clothes in vacuum bags is often marketed as the ultimate space-saver, it is a high-stakes gamble for your wardrobe. By stripping away the air, you are also stripping away the garment’s structural integrity, inviting deep-set creases and trapped moisture that can ruin delicate fibers. The secret to...

4
0
2
bottom of page