Design a Logistics System (Object Oriented Design). Tell about the different classes and their relationships with each-other. It is not a System Design question, so scope of this question is only to define different classes (with it’s attributes and methods)
Asked In: Adobe
Solution: Let’s assume we want to design a Logistics System with following basic functionality:
• The system can take an order to deliver it to a given destination.
• The order will be a list of items and there is a cost of each order to process.
• User has to register himself / herself to use this system.
• User can track his / her order.
• Orders will be shipped by bike or truck, but only a single order will be shipped by a single vehicle.
These type of questions are asked in interviews to Judge the Object Oriented Design skill of a candidate. So, first of all we should think about the classes.
The main classes will be:
The User class is for users/clients/customers, who will be charged to get their items delivered.
Item class represents an item which will be shipped. An order will contain a list of items.
Location class simply represents the address.
The Vehicle class represents the vehicle which will be used to ship/deliver an order.
It will be of two types: 1. Bike and 2. Truck
The bike has only 10 unit of capacity.
The truck has only 100 unit of capacity (10 times more than bike).
Enum for current status of a vehicle:
Enum for OrderPriority:
Enum for OrderStatus:
Enum for PaymentMode:
Enum for PaymentStatus:
The PaymentDetails class contains the information of payment related things so that in any case the order is cancelled, it can be refunded easily.
The Order class contains all the information of an order. All fields are self-explanatory.
The main class (LogisticsSystem) which stores all the information of users, orders and vehicles. It has the methods like takeAnOrder(), processOrder() etc.
This is the test class to test the application.