- The online shopping service should allow users to browse products, add them to the shopping cart, and place orders.
- The system should support multiple product categories and provide search functionality.
- Users should be able to manage their profiles, view order history, and track order status.
- The system should handle inventory management and update product availability accordingly.
- The system should support multiple payment methods and ensure secure transactions.
- The system should handle concurrent user requests and ensure data consistency.
- The system should be scalable to handle a large number of products and users.
- The system should provide a user-friendly interface for a seamless shopping experience.
- The User class represents a user in the online shopping service, with properties such as ID, name, email, password, and a list of orders.
- The Product class represents a product available for purchase, with properties like ID, name, description, price, and quantity. It provides methods to update the quantity and check product availability.
- The Order class represents an order placed by a user, containing properties such as ID, user, order items, total amount, and order status. It calculates the total amount based on the order items.
- The OrderItem class represents an item within an order, consisting of the product and the quantity ordered.
- The OrderStatus enum represents the different statuses an order can have, such as pending, processing, shipped, delivered, or cancelled.
- The ShoppingCart class represents the user's shopping cart, allowing them to add, remove, and update item quantities. It maintains a map of product IDs and order items.
- The Payment interface defines the contract for processing payments, with a concrete implementation CreditCardPayment.
- The OnlineShoppingService class is the central component of the online shopping service. It follows the Singleton pattern to ensure only one instance of the service exists. It provides methods to register users, add products, search products, place orders, and retrieve order information. It handles concurrent access to shared resources using synchronization.
- The OnlineShoppingServiceDemo class demonstrates the usage of the online shopping service by registering users, adding products, searching for products, placing orders, and viewing order history.