mjain

Online Shopping OOPS design

Jul 24th, 2019
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.77 KB | None | 0 0
  1. package onlineShoppingSystem;
  2.  
  3. import java.util.Date;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. public class OnlineShoppingSystem {
  9.  
  10.     public enum AccountStatus {
  11.         ACTIVE, BLOCKED, BANNED, COMPROMISED, UNKNOWN;
  12.     }
  13.     public enum OrderStatus {
  14.         UNSHIPPED, PENDING, SHIPPED, COMPLETED, CANCELED, REFUND_APPLIED
  15.     }
  16.     public enum ShipmentStatus {
  17.         PENDING, SHIPPED, DELIVERED, ON_HOLD,
  18.     }
  19.  
  20.     public class Account {
  21.         String        name;
  22.         String        uName;
  23.         String        password;
  24.         String        email;
  25.         String        mobile;
  26.         AccountStatus status;
  27.  
  28.     }
  29.  
  30.     public class OrderLog {
  31.         String      orderid;
  32.         OrderStatus ostatus;
  33.         Date        createdTime;
  34.     }
  35.  
  36.     public class Order {
  37.         String         orderNumner;
  38.         Date           createdTime;
  39.         List<OrderLog> logs;
  40.         OrderStatus    staus;
  41.  
  42.         // public boolean sendForShipment();
  43.         // public boolean makePayment(Payment payment);
  44.         // public boolean addOrderLog(OrderLog orderLog);
  45.     }
  46.  
  47.     public class ProductCategory {
  48.         String name;
  49.         String description;
  50.     }
  51.     public class Product {
  52.         ProductCategory category;
  53.         String          productId;
  54.         String          name;
  55.         String          description;
  56.         double          price;
  57.         int             availableCount;
  58.         Account         supplier;
  59.  
  60.         public int getAvailableCount() {
  61.             return availableCount;
  62.         }
  63.  
  64.         public boolean updatePrice(double newPrice) {
  65.             return true;
  66.         }
  67.  
  68.     }
  69.     public class ProductReview {
  70.         String review;
  71.         double ratign;
  72.         // Member reviewer;
  73.     }
  74.     public class Shipment {
  75.         private String shipmentNumber;
  76.         private Date   shipmentDate;
  77.         private Date   estimatedArrival;
  78.         private String shipmentMethod;
  79.  
  80.         // public boolean addShipmentLog(ShipmentLog shipmentLog);
  81.     }
  82.  
  83.     public class ShipmentLogs {
  84.         String         shipmentNumber;
  85.         ShipmentStatus status;
  86.         Date           createdTime;
  87.     }
  88.     public abstract class Customer {
  89.         ShoopingCart cart;
  90.         Order        order;
  91.         // public ShoppingCart getShoppingCart();
  92.         // public bool addItemToCart(Item item);
  93.         // public bool removeItemFromCart(Item item);
  94.  
  95.     }
  96.     public class Guest extends Customer {
  97.  
  98.         // public registerAccounr();
  99.     }
  100.  
  101.     public class Member extends Customer {
  102.  
  103.         Account account;
  104.         // public OrderStatus placeOrder(Order order);
  105.     }
  106.  
  107.     public class CartItem {
  108.         int    productId;
  109.         int    quanitiy;
  110.         double price;
  111.  
  112.     }
  113.  
  114.     public class ShoopingCart {
  115.         List<CartItem> itemList;
  116.         // public boolean addItem(CartItem item){};
  117.         // public boolean removeItem(CartItem item);
  118.         // public boolean updateItemQuantity(CartItem item, int quantity);
  119.         // public List<CartItem> getItems();
  120.         // public boolean checkout();
  121.     }
  122.  
  123.     public interface Search {
  124.         public List<Product> searchProductsByName(String name);
  125.  
  126.         public List<Product> searchProductsByCategory(String category);
  127.     }
  128.     public class Catalogue implements Search {
  129.  
  130.         Map<String, List<Product>>     productNames;
  131.         HashMap<String, List<Product>> productCategories;
  132.  
  133.         @Override
  134.         public List<Product> searchProductsByName(String name) {
  135.             return productNames.get(name);
  136.         }
  137.  
  138.         @Override
  139.         public List<Product> searchProductsByCategory(String category) {
  140.             return productCategories.get(category);
  141.         }
  142.  
  143.     }
  144. }
Add Comment
Please, Sign In to add comment