Design a Logistics System


  • 47

    We have to design a logistics system where a client can place an order to get his/her items delivered to a given destination .
    We have to keep track of status of all the orders . The admin of logistics charges some amount for delivering the orders (Items).

    My Solution :

    classes :

    1. Vehicle (Extended by Truck, Bike )
    2. Order
    3. Item
    4. Location (for geographical position of any point)
    5. Client
    6. Admin

    Enums :

    public enum VehicleStatus {
        FREE ,
        BUSY ,
        NOT_WORKING;
    }
    
    public enum OrderStatus {
        DELIVERED ,
        PROCESSING , 
        CANCELLED; 
    }
    
    public enum PaymentStatus {
        PAID,
        UNPAID;
    }
    
    public enum OrderPriority {
        LOW,
        MEDIUM,
        HIGH;
    }
    
    // for geographical position of any point
    class Location {
    	float longitude;
    	float latitude;
    }
    
    // for the vehicles used for transportation
    class Vehicle {
    	
    	int id;
    	String vehicleNo;
    	int capacity;
    	Location current_position;
    	VehicleStatus current_condition;
    }
    
    class Truck extends Vehicles{
    
    }
    
    class Bike extends Vehicles{
    
    }
    
    // a new order is created for each order place by any client
    class Order{
    	int order_id;
    	OrderPriority priority_of_order;
        Client owner_of_order;
        Location destination;
        int amount_of_charge;
        List<Item> items;
        int total_weight;
        OrderStatus current_status;
        PaymentStatus status_of_payment;
        Time time_of_order_placed;
        Time time_of_delivery
    
    }
    
    // An order is List of Items
    class Item {
    	String name;
    	int price;
    	int volume;
    	int weight;
    }
    
    class Client {
    	int client_id;
    	String name;
    	Location adress;
    }
    
    class Admin{
    void take_order (Order order)
    void process_order(Order order)
    Location track_order(int order_id)
    }
    

    You can connect with me here: https://www.linkedin.com/in/shashi-bhushan-kumar-709a05b5/


  • 0
    L

    great solution....


  • 0
    A

    @shashipk11 Nice Solution!


  • 0

    Very easy to understand. Great work


  • 0
    P

    nice Solution .(y)


  • 0
    P

    easy to understand


  • 0
    S

    Very nice solution!


  • 0
    C

    @shashipk11 good Solution


  • 1

    @cc19930529 Thanks a lot !!


  • 1
    S

    hope you got offer :)


  • 1

    @sha256pki Yes Bro :) !!


  • 0
    A

    @shashibk11 Hi... the order can take multiple attempts to deliver? Or is one to one, if you cant delivery for any reason the order is clodes anyway, want another attempt? place a new order?


  • 0

    @antonio.trujillo01 We will persist all the Entities (including 'Oreder') in DB.
    If an order could not delivered, we can update the current status (it can be DELIVERED ,PROCESSING or CANCELLED) in DB. In case it is not delivered, we will update the status as "PROCESSING" if we want to try again.

    We will have a background job (Sheduler you can say), that will pick all the orders that are unsuccessful and call the method process_order(Order order).

    I am working on a Spring (Java) Web Application to implement this. I will post here once it is completed.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.