├── LoginPackage ├── Request.java ├── Session.java ├── Services │ ├── Authorizer.java │ ├── Decoder.java │ ├── Authenticator.java │ └── Encoder.java ├── Cookie.java ├── Helpers.java ├── LoginManager.java ├── readme.md └── LoginManager ├── .gitignore ├── GooglePhotos └── readme.md ├── JobScheduler └── readme.md ├── WebCrawler └── readme.md ├── SubscriptionService └── readme.md ├── DeliveryRouteService └── readme.md ├── SnakeLadder ├── Board.java ├── Game.java ├── CellFactory.java ├── Player.java ├── PlayerFactory.java ├── Cell.java ├── EmptyCell.java ├── SnakeCell.java ├── AiPlayer.java ├── LadderCell.java ├── HumanPlayer.java ├── Snake&Ladder.drawio.png ├── readme.md └── Snake&Ladder.drawio ├── TaskPlanner ├── Bug.java ├── Roles.java ├── Story.java ├── Task.java ├── User.java ├── Project.java ├── Sprint.java ├── IStatusFlow.java ├── Tracker.java ├── TrackerFactory.java ├── StatusFlowFActory.java ├── BugStatusFlow.java ├── TaskStatusFlow.java ├── StoryStatusFlow.java ├── TaskPlanner.drawio.png ├── readme.md └── TaskPlanner.drawio ├── TicTacToe ├── User.java ├── IStrategy.java ├── AiPlayer.java ├── EasyLevelStrategy.java ├── HardLevelStrategy.java ├── MediumLevelStrategy.java ├── Player.java ├── Constants.java ├── Board.java ├── readme.md ├── HumanPlayer.java ├── Client.java └── Game.java ├── AnalyticsPipeline ├── src │ ├── controllers │ │ └── ClickStreamController.py │ ├── config │ │ └── Config.py │ ├── routes │ │ └── FunnelRoutes.py │ ├── models │ │ └── ClickStreamModel.py │ ├── app.py │ ├── services │ │ └── Analytics.py │ └── repos │ │ ├── AbstractRepo.py │ │ └── ClickStreamDynamoRepo.py └── readme.md ├── QnAPortal └── readme.md ├── Splitwise ├── .idea │ ├── .gitignore │ ├── codeStyles │ │ ├── codeStyleConfig.xml │ │ └── Project.xml │ ├── misc.xml │ ├── vcs.xml │ ├── modules.xml │ └── runConfigurations.xml ├── models │ ├── Role.java │ ├── BaseModel.java │ ├── Pair.java │ ├── User.java │ ├── Txn.java │ ├── Group.java │ └── Expense.java ├── Factory │ └── StrategyFactory.java ├── Utilities │ └── CommandExecutor.java ├── Splitwise.drawio.png ├── Strategy │ ├── SplitStrategy.java │ ├── SplitEqually.java │ ├── SplitByPercent.java │ └── SplitByUserInp.java ├── Controllers │ ├── ExpenseController.java │ ├── TransactionController.java │ ├── GroupController.java │ ├── DTO │ │ └── Response.java │ └── UserController.java ├── Services │ ├── ExpenseService.java │ ├── TxnService.java │ ├── GroupService.java │ └── UserService.java ├── Config │ └── Constants.java ├── Repository │ ├── IRepository.java │ ├── UserRepository.java │ ├── Expenserepository.java │ ├── TxnRepository.java │ └── GroupRepository.java ├── Splitwise.iml ├── client.java ├── readme.md └── Splitwise.drawio ├── ParkingLot ├── models │ ├── User.java │ ├── Ticket.java │ ├── EntryPoint.java │ ├── ExitPoint.java │ ├── AccessPoint.java │ ├── Constants.java │ ├── Vehicle.java │ ├── ParkingSlot.java │ ├── client.java │ ├── ParkingFloor.java │ └── ParkingLot.java ├── services │ ├── Payment.java │ ├── IPricingStrategy.java │ ├── SlotsInventoryService.java │ ├── FullDayStrategy.java │ ├── BaseHourlyStrategy.java │ ├── FloorHourlyStrategy.java │ └── BookingSlotService.java └── readme.md ├── CartService ├── Model │ ├── Products.java │ ├── BaseModel.java │ └── CartModel.java ├── Service │ ├── CartService.java │ ├── OrderService.java │ └── BillingService.java ├── Middleware │ └── RequestMiddleware.java ├── Contorller │ └── CartController.java ├── Repository │ ├── CacheRepo.java │ ├── CartRepo.java │ ├── ProductsRepo.java │ └── IRepo.java └── readme.md ├── .vscode └── settings.json ├── PaymentService └── readme.md └── README.md /LoginPackage/Request.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LoginPackage/Session.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Analytics/venv/ 2 | -------------------------------------------------------------------------------- /LoginPackage/Services/Authorizer.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LoginPackage/Services/Decoder.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /GooglePhotos/readme.md: -------------------------------------------------------------------------------- 1 | ## To be added 2 | -------------------------------------------------------------------------------- /JobScheduler/readme.md: -------------------------------------------------------------------------------- 1 | ## To be added 2 | -------------------------------------------------------------------------------- /LoginPackage/Services/Authenticator.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /WebCrawler/readme.md: -------------------------------------------------------------------------------- 1 | ## To be added 2 | -------------------------------------------------------------------------------- /SubscriptionService/readme.md: -------------------------------------------------------------------------------- 1 | ## To be added 2 | -------------------------------------------------------------------------------- /DeliveryRouteService/readme.md: -------------------------------------------------------------------------------- 1 | ## To be added 2 | -------------------------------------------------------------------------------- /SnakeLadder/Board.java: -------------------------------------------------------------------------------- 1 | public class Board{ 2 | 3 | } -------------------------------------------------------------------------------- /SnakeLadder/Game.java: -------------------------------------------------------------------------------- 1 | public class Game{ 2 | 3 | } -------------------------------------------------------------------------------- /TaskPlanner/Bug.java: -------------------------------------------------------------------------------- 1 | public class Bug { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/User.java: -------------------------------------------------------------------------------- 1 | public class User { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /LoginPackage/Cookie.java: -------------------------------------------------------------------------------- 1 | public class Cookie{ 2 | 3 | } -------------------------------------------------------------------------------- /TaskPlanner/Roles.java: -------------------------------------------------------------------------------- 1 | public class Roles { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/Story.java: -------------------------------------------------------------------------------- 1 | public class Story { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/Task.java: -------------------------------------------------------------------------------- 1 | public class Task { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/User.java: -------------------------------------------------------------------------------- 1 | public class User { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/controllers/ClickStreamController.py: -------------------------------------------------------------------------------- 1 | .. 2 | -------------------------------------------------------------------------------- /LoginPackage/Helpers.java: -------------------------------------------------------------------------------- 1 | public class Helpers { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /SnakeLadder/CellFactory.java: -------------------------------------------------------------------------------- 1 | public class CellFactory{ 2 | 3 | } -------------------------------------------------------------------------------- /SnakeLadder/Player.java: -------------------------------------------------------------------------------- 1 | public abstract class Player { 2 | 3 | } -------------------------------------------------------------------------------- /SnakeLadder/PlayerFactory.java: -------------------------------------------------------------------------------- 1 | public class PlayerFactory{ 2 | 3 | } -------------------------------------------------------------------------------- /TaskPlanner/Project.java: -------------------------------------------------------------------------------- 1 | public class Project { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/Sprint.java: -------------------------------------------------------------------------------- 1 | public class Sprint { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /LoginPackage/LoginManager.java: -------------------------------------------------------------------------------- 1 | public class LoginManager{ 2 | 3 | } -------------------------------------------------------------------------------- /QnAPortal/readme.md: -------------------------------------------------------------------------------- 1 | # Design QnA at Scale 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SnakeLadder/Cell.java: -------------------------------------------------------------------------------- 1 | public abstract class Cell { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/IStrategy.java: -------------------------------------------------------------------------------- 1 | public interface IStrategy { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /SnakeLadder/EmptyCell.java: -------------------------------------------------------------------------------- 1 | public class EmptyCell extends Cell{ 2 | 3 | } -------------------------------------------------------------------------------- /SnakeLadder/SnakeCell.java: -------------------------------------------------------------------------------- 1 | public class SnakeCell extends Cell{ 2 | 3 | } -------------------------------------------------------------------------------- /TaskPlanner/IStatusFlow.java: -------------------------------------------------------------------------------- 1 | public interface IStatusFlow { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/Tracker.java: -------------------------------------------------------------------------------- 1 | public abstract class Tracker { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/config/Config.py: -------------------------------------------------------------------------------- 1 | #Add dynamo DB connections here 2 | 3 | -------------------------------------------------------------------------------- /SnakeLadder/AiPlayer.java: -------------------------------------------------------------------------------- 1 | public class AiPlayer extends Player { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /SnakeLadder/LadderCell.java: -------------------------------------------------------------------------------- 1 | public class LadderCell extends Cell{ 2 | 3 | } -------------------------------------------------------------------------------- /TaskPlanner/TrackerFactory.java: -------------------------------------------------------------------------------- 1 | public class TrackerFactory { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/AiPlayer.java: -------------------------------------------------------------------------------- 1 | public class AiPlayer extends Player{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/routes/FunnelRoutes.py: -------------------------------------------------------------------------------- 1 | #add funnel related apis routes here 2 | -------------------------------------------------------------------------------- /Splitwise/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /TaskPlanner/StatusFlowFActory.java: -------------------------------------------------------------------------------- 1 | public class StatusFlowFActory { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /ParkingLot/models/User.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class User { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /SnakeLadder/HumanPlayer.java: -------------------------------------------------------------------------------- 1 | public class HumanPlayer extends Player { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /Splitwise/models/Role.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Role { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Model/Products.java: -------------------------------------------------------------------------------- 1 | package Model; 2 | 3 | public class Products { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/models/Ticket.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Ticket { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/models/ClickStreamModel.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class ClickStream: 4 | id=0 5 | 6 | -------------------------------------------------------------------------------- /CartService/Model/BaseModel.java: -------------------------------------------------------------------------------- 1 | package Model; 2 | 3 | public class BaseModel { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Model/CartModel.java: -------------------------------------------------------------------------------- 1 | package Model; 2 | 3 | public class CartModel { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/models/EntryPoint.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class EntryPoint { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/models/ExitPoint.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class ExitPoint { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/services/Payment.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | public class Payment { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TaskPlanner/BugStatusFlow.java: -------------------------------------------------------------------------------- 1 | public class BugStatusFlow implements IStatusFlow{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TaskPlanner/TaskStatusFlow.java: -------------------------------------------------------------------------------- 1 | public class TaskStatusFlow implements IStatusFlow{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /CartService/Service/CartService.java: -------------------------------------------------------------------------------- 1 | package Service; 2 | 3 | public class CartService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TaskPlanner/StoryStatusFlow.java: -------------------------------------------------------------------------------- 1 | public class StoryStatusFlow implements IStatusFlow{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/EasyLevelStrategy.java: -------------------------------------------------------------------------------- 1 | public class EasyLevelStrategy implements IStrategy{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/HardLevelStrategy.java: -------------------------------------------------------------------------------- 1 | public class HardLevelStrategy implements IStrategy{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /TicTacToe/MediumLevelStrategy.java: -------------------------------------------------------------------------------- 1 | public class MediumLevelStrategy implements IStrategy{ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /CartService/Service/OrderService.java: -------------------------------------------------------------------------------- 1 | package Service; 2 | 3 | public class OrderService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Middleware/RequestMiddleware.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | public class RequestMiddleware { 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ParkingLot/models/AccessPoint.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public abstract class AccessPoint { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Factory/StrategyFactory.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | public class StrategyFactory { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Utilities/CommandExecutor.java: -------------------------------------------------------------------------------- 1 | package Utilities; 2 | 3 | public class CommandExecutor { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Contorller/CartController.java: -------------------------------------------------------------------------------- 1 | package Contorller; 2 | 3 | public class CartController { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Service/BillingService.java: -------------------------------------------------------------------------------- 1 | package Service; 2 | 3 | 4 | public class BillingService { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /LoginPackage/Services/Encoder.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | //encoder decoder 3 | public class Encoder { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/services/IPricingStrategy.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | public interface IPricingStrategy { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Splitwise.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearningsLab/BoilerPlates/HEAD/Splitwise/Splitwise.drawio.png -------------------------------------------------------------------------------- /Splitwise/Strategy/SplitStrategy.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | public abstract class SplitStrategy { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/services/SlotsInventoryService.java: -------------------------------------------------------------------------------- 1 | package services; 2 | public class SlotsInventoryService { 3 | 4 | } 5 | -------------------------------------------------------------------------------- /Splitwise/Controllers/ExpenseController.java: -------------------------------------------------------------------------------- 1 | package Controllers; 2 | 3 | public class ExpenseController { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CartService/Repository/CacheRepo.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | 4 | public class CacheRepo implements IRepo{ 5 | 6 | } 7 | -------------------------------------------------------------------------------- /CartService/Repository/CartRepo.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | 4 | public class CartRepo implements IRepo { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /SnakeLadder/Snake&Ladder.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearningsLab/BoilerPlates/HEAD/SnakeLadder/Snake&Ladder.drawio.png -------------------------------------------------------------------------------- /Splitwise/Strategy/SplitEqually.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | public class SplitEqually extends SplitStrategy { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TaskPlanner/TaskPlanner.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearningsLab/BoilerPlates/HEAD/TaskPlanner/TaskPlanner.drawio.png -------------------------------------------------------------------------------- /CartService/Repository/ProductsRepo.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | 4 | public class ProductsRepo implements IRepo { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /Splitwise/Controllers/TransactionController.java: -------------------------------------------------------------------------------- 1 | package Controllers; 2 | 3 | public class TransactionController { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Strategy/SplitByPercent.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | public class SplitByPercent extends SplitStrategy{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Strategy/SplitByUserInp.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | public class SplitByUserInp extends SplitStrategy { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TicTacToe/Player.java: -------------------------------------------------------------------------------- 1 | public abstract class Player{ 2 | 3 | private int user_id; 4 | private Constants.Symbols symbol; 5 | 6 | } -------------------------------------------------------------------------------- /ParkingLot/services/FullDayStrategy.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | public class FullDayStrategy implements IPricingStrategy{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/services/BaseHourlyStrategy.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | public class BaseHourlyStrategy implements IPricingStrategy{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /ParkingLot/services/FloorHourlyStrategy.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | public class FloorHourlyStrategy implements IPricingStrategy{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Splitwise/Services/ExpenseService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import models.Expense; 4 | 5 | public class ExpenseService { 6 | 7 | 8 | } 9 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/') 6 | def gatherData: 7 | return "Hello World! I am doing my job!!" 8 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/services/Analytics.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Analytics: 4 | def getCheckoutFunnel(merchant): 5 | return 6 | def getECR(merchant): 7 | return 8 | -------------------------------------------------------------------------------- /Splitwise/.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /Splitwise/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Splitwise/Config/Constants.java: -------------------------------------------------------------------------------- 1 | package Config; 2 | 3 | public class Constants { 4 | public enum SplitStrategy{ 5 | UserCurrecny, 6 | Equally, 7 | ByPercentage 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Splitwise/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Splitwise/models/BaseModel.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | import java.util.Date; 4 | 5 | public abstract class BaseModel { 6 | Long id; 7 | Date createdAt; 8 | Date modifiedAt; 9 | Boolean status; 10 | } 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.project.sourcePaths": [ 3 | "TicTacToe", 4 | "Chess", 5 | "ParkingLot", 6 | "SnakeLadder", 7 | "LoginPackage", 8 | "TaskPlanner", 9 | "Splitwise", 10 | "CartService" 11 | ] 12 | } -------------------------------------------------------------------------------- /AnalyticsPipeline/src/repos/AbstractRepo.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta 2 | 3 | class abcRepo(metaclass=ABCMeta): 4 | def create(): 5 | return 6 | def update(): 7 | return 8 | def delete(): 9 | return 10 | def findbyId(): 11 | return 12 | -------------------------------------------------------------------------------- /AnalyticsPipeline/src/repos/ClickStreamDynamoRepo.py: -------------------------------------------------------------------------------- 1 | import abstractrepo 2 | 3 | class DynamoRepo(abcRepo): 4 | def create(): 5 | return 6 | def update(): 7 | return 8 | def delete(): 9 | return 10 | def findbyId(): 11 | return 12 | -------------------------------------------------------------------------------- /TicTacToe/Constants.java: -------------------------------------------------------------------------------- 1 | public interface Constants{ 2 | enum Level { 3 | EASY, 4 | MEDIUM, 5 | HARD 6 | } 7 | enum Symbols{ 8 | ZERO, 9 | CROSS 10 | } 11 | enum GameStatus{ 12 | RUNNIG, 13 | CLOSED 14 | } 15 | } -------------------------------------------------------------------------------- /Splitwise/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Splitwise/models/Pair.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Pair { 4 | T fst; 5 | T snd; 6 | 7 | public Pair(T fst, T snd) { 8 | this.fst = fst; 9 | this.snd = snd; 10 | } 11 | 12 | T getFst() { return fst; } 13 | 14 | T getSnd() { return snd; } 15 | } 16 | -------------------------------------------------------------------------------- /PaymentService/readme.md: -------------------------------------------------------------------------------- 1 | ## Requirements 2 | 3 | - User shall be able to pay using CC/DC, Wallets + UPI methods 4 | - User shall be able to see discount on each method if applicable 5 | - User shall be able to save card for faster payments 6 | - User shall be able to retry if payment fails 7 | - User shall be see pending payment orders -------------------------------------------------------------------------------- /CartService/Repository/IRepo.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | public interface IRepo{ 4 | 5 | // public void create(E obj); 6 | 7 | // public Optional findbyId(Id id); 8 | 9 | // public List findAll(Id id); 10 | 11 | // public void save(E obj); 12 | 13 | // public void delete(Id id); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /ParkingLot/models/Constants.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public interface Constants { 4 | enum SlotOrVehicleTypes{ 5 | CAR, 6 | TRUCK, 7 | BIKE 8 | } 9 | enum VehicleType { 10 | CAR, 11 | TRUCK, 12 | BIKE 13 | } 14 | enum ParkStatus{ 15 | SUCESS, 16 | FAIL 17 | } 18 | final static int MaxSlotsPerFloor=20; 19 | } 20 | -------------------------------------------------------------------------------- /Splitwise/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /TicTacToe/Board.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | //import java.util.List; 3 | 4 | public class Board{ 5 | private ArrayList> state = new ArrayList<>(); 6 | 7 | public ArrayList> getState(){ 8 | return this.state; 9 | } 10 | 11 | public void setState(ArrayList> state){ 12 | this.state=state; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /Splitwise/Repository/IRepository.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface IRepository{ 7 | 8 | // public void create(E obj); 9 | 10 | // public Optional findbyId(Id id); 11 | 12 | // public List findAll(Id id); 13 | 14 | // public void save(E obj); 15 | 16 | // public void delete(Id id); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Splitwise/Splitwise.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /TicTacToe/readme.md: -------------------------------------------------------------------------------- 1 | # Design a TicTacToe 2 | 3 | ## Requirements 4 | - User shall play as per his turn 5 | 6 | ## Translation into Objects 7 | - To be added 8 | 9 | 10 | ## Expected Queries 11 | - To be added 12 | 13 | ## Class Diagram Walk Through 14 | - To be added 15 | 16 | 17 | ### ClassDiagram 18 | - To be added 19 | 20 | ### Code 21 | [Code](https://github.com/LearningsLab/BoilerPlates/tree/main/TicTacToe) 22 | 23 | ### [RepoWebLink](https://learningslab.github.io/BoilerPlates) -------------------------------------------------------------------------------- /Splitwise/Repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | import java.util.ArrayList; 4 | 5 | import models.User; 6 | 7 | public class UserRepository implements IRepo{ 8 | private ArrayList userrepo; 9 | 10 | public UserRepository(ArrayList users){ 11 | this.userrepo=users; 12 | } 13 | 14 | public User registeruser(User user){ 15 | this.userrepo.add(user); 16 | return this.userrepo.get(this.userrepo.size()-1); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /AnalyticsPipeline/readme.md: -------------------------------------------------------------------------------- 1 | ## Designing Anaylytics Service 2 | 3 | 4 | 5 | ### Current Requirements 6 | - Given a clickstream data,Shall be able to proive User jounrney Funnel from landing a page to final buying a product with payment. 7 | - Shall be able to provide conversion rates of various categories of product 8 | - Mostly Data is in redshift, some of it is still hanging in NOSQL DYnamo DB 9 | 10 | ### Future Scope 11 | - We have may have to migrate some data from other sources to redshift 12 | 13 | - 14 | 15 | -------------------------------------------------------------------------------- /ParkingLot/services/BookingSlotService.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | import models.ParkingLot; 4 | import models.*; 5 | 6 | public class BookingSlotService { 7 | private ParkingLot pLot; 8 | 9 | public BookingSlotService(ParkingLot parkingLot){ 10 | this.pLot=parkingLot; 11 | } 12 | 13 | public Boolean bookSlot(){ 14 | //get free slot on any of parking floor 15 | ParkingSlot pSlot=this.pLot.getFreeSlot(); 16 | Boolean isBooked = pSlot.setBooked(true); 17 | return isBooked; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Splitwise/models/User.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class User extends BaseModel{ 4 | private String emailId; 5 | private String name; 6 | private String mobNo; 7 | 8 | public User(String email, String name, String phNo){ 9 | this.emailId=email; 10 | this.mobNo=phNo; 11 | this.name=name; 12 | } 13 | public String getEmail(){ 14 | return this.emailId; 15 | } 16 | public String getName(){ 17 | return this.name; 18 | } 19 | public String getPhNo(){ 20 | return this.mobNo; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Splitwise/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /Splitwise/Repository/Expenserepository.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | import java.util.ArrayList; 3 | 4 | import models.Expense; 5 | // import models.Group; 6 | // import models.Expense; 7 | public class Expenserepository implements IRepo{ 8 | private ArrayList expenseRepo; 9 | 10 | public Expenserepository(ArrayList expenses){ 11 | this.expenseRepo=expenses; 12 | } 13 | 14 | public Expense addExpense(Expense expense){ 15 | this.expenseRepo.add(expense); 16 | return this.expenseRepo.get(this.expenseRepo.size()-1); 17 | } 18 | 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Splitwise/Repository/TxnRepository.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | import java.util.ArrayList; 4 | 5 | import models.Txn; 6 | 7 | public class TxnRepository implements IRepo { 8 | 9 | private static TxnRepository txnRepo=null; 10 | private ArrayList txnsRepo; 11 | public static TxnRepository getInstance(){ 12 | if (txnRepo==null){ 13 | txnRepo = new TxnRepository(); 14 | } 15 | return txnRepo; 16 | } 17 | 18 | public Txn addTxn(Txn txn){ 19 | this.txnsRepo.add(txn); 20 | return this.txnsRepo.get(this.txnsRepo.size()-1); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ParkingLot/models/Vehicle.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Vehicle { 4 | private int id; 5 | private String identifier; 6 | private Constants.SlotOrVehicleTypes vtype; 7 | 8 | public Vehicle(int id,String registry,Constants.SlotOrVehicleTypes val){ 9 | this.id=id; 10 | this.identifier=registry; 11 | this.vtype=val; 12 | } 13 | public String getVehicleRegistry(){ 14 | return this.identifier; 15 | } 16 | public int getVehicleId(){ 17 | return this.id; 18 | } 19 | public Constants.SlotOrVehicleTypes getVehicleType(){ 20 | return this.vtype; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Splitwise/models/Txn.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Txn extends BaseModel { 4 | private User payer; 5 | private User receiver; 6 | private Group grp; 7 | private Float amt; 8 | public Txn(User payer,User receiver,Group grp,Float amount){ 9 | this.payer=payer; 10 | this.receiver=receiver; 11 | this.grp=grp; 12 | this.amt=amount; 13 | } 14 | public Float getTxnAmt(){ 15 | return this.amt; 16 | } 17 | public User getPayer(){ 18 | return this.payer; 19 | } 20 | public User getReceiver(){ 21 | return this.receiver; 22 | } 23 | public Group getGrp(){ 24 | return this.grp; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /TicTacToe/HumanPlayer.java: -------------------------------------------------------------------------------- 1 | 2 | public class HumanPlayer extends Player { 3 | private int user_id; 4 | 5 | public int getUser_id() { 6 | return user_id; 7 | } 8 | 9 | public void setUser_id(int user_id) { 10 | this.user_id = user_id; 11 | } 12 | 13 | public static class Builder { 14 | private HumanPlayer player; 15 | 16 | public Builder() { 17 | this.player = new HumanPlayer(); 18 | } 19 | 20 | public Builder withUserId(int user_id) { 21 | this.player.setUser_id(user_id); 22 | return this; 23 | } 24 | 25 | public HumanPlayer build() { 26 | return this.player; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Splitwise/Services/TxnService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import java.util.ArrayList; 4 | 5 | import Repository.TxnRepository; 6 | import models.Txn; 7 | 8 | public class TxnService { 9 | private static TxnRepository txnRepo=null; 10 | 11 | // public TxnService(){ 12 | // this.txnRepo = new TxnRepository(); 13 | 14 | // } 15 | 16 | public TxnRepository getInstance(){ 17 | if (txnRepo==null){ 18 | txnRepo = new TxnRepository(); 19 | } 20 | return txnRepo; 21 | } 22 | 23 | public void addTxns(ArrayList txns){ 24 | for (Txn txn : txns) { 25 | this.txnRepo.addTxn(txn); 26 | 27 | } 28 | 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Splitwise/Controllers/GroupController.java: -------------------------------------------------------------------------------- 1 | package Controllers; 2 | 3 | import Services.GroupService; 4 | import models.*; 5 | 6 | public class GroupController { 7 | private static GroupController grpController=null; 8 | private GroupService grpService; 9 | public static GroupController getInstance(){ 10 | if (grpController==null){ 11 | grpController=new GroupController(); 12 | grpController.grpService = new GroupService(); 13 | } 14 | return grpController; 15 | } 16 | 17 | public Group CreatetGrp(User user){ 18 | Group grp=grpController.grpService.createGrp(user); 19 | return grp; 20 | } 21 | public GroupService getgrpService(){ 22 | return grpController.grpService; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /TicTacToe/Client.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | //import 3 | 4 | //import Game.Builder; 5 | 6 | public class Client { 7 | // board=createboard() 8 | // Game=new Game(board(3) 9 | //create a board of dimension NXN 10 | // create a Game 11 | // create set 2 players 12 | // build a player 13 | // choose difficulty if there is an AiPlayer involved 14 | //start the game 15 | public static void main(String[] args) { 16 | ArrayList> board = new ArrayList>(); 17 | Board brd=new Board(); 18 | Game game =new Game.Builder().setBoardDimension(3, 3).addPlayer(new HumanPlayer.Builder().withUserId(123).build() 19 | ).addPlayer(new HumanPlayer.Builder().withUserId(123).build()).build(); 20 | //game.run() 21 | } 22 | 23 | 24 | } 25 | //new keyword 26 | -------------------------------------------------------------------------------- /LoginPackage/readme.md: -------------------------------------------------------------------------------- 1 | # Design a Login Manager 2 | 3 | ## Requirements 4 | - It shall authorize all the requests 5 | - It shall authenticate the user 6 | - It shall support different most common ways to authorize requests. 7 | 8 | ## Future Scope to add fishes in board 9 | - It might be used as a package in future 10 | 11 | ## Translation into Objects 12 | - Model 13 | - LoginManager 14 | - Cookie 15 | - Request 16 | - Services 17 | - Encoding/decoding 18 | - Validation 19 | - Response handler 20 | - Authorizer 21 | - Authenticator 22 | 23 | ## Expected Queries 24 | - To be added 25 | 26 | ## Class Diagram Walk Through 27 | To be added 28 | 29 | 30 | ### ClassDiagram 31 | To be added 32 | 33 | ### Code 34 | [Link](https://github.com/LearningsLab/BoilerPlates/tree/main/LoginPackage) 35 | 36 | ### [RepoWebLink](https://learningslab.github.io/BoilerPlates) -------------------------------------------------------------------------------- /Splitwise/Controllers/DTO/Response.java: -------------------------------------------------------------------------------- 1 | package Controllers.DTO; 2 | 3 | public class Response { 4 | private Boolean status; 5 | private String msg; 6 | private String responseCode; 7 | public Response(Boolean status,String msg,String responseCode){ 8 | this.status=status; 9 | this.msg=msg; 10 | this.responseCode=responseCode; 11 | } 12 | 13 | public Boolean getStatus() { 14 | return status; 15 | } 16 | 17 | public String getMsg() { 18 | return msg; 19 | } 20 | 21 | public String getResponseCode() { 22 | return responseCode; 23 | } 24 | 25 | public void setStatus(Boolean status) { 26 | this.status = status; 27 | } 28 | 29 | public void setMsg(String msg) { 30 | this.msg = msg; 31 | } 32 | 33 | public void setResponseCode(String responseCode) { 34 | this.responseCode = responseCode; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ParkingLot/readme.md: -------------------------------------------------------------------------------- 1 | # Design ParkingLot 2 | 3 | ## Requirements 4 | - User shall be able to park his car 5 | - User shall be able to unpark his car 6 | - Parking Lot has attendants on entry and exit points 7 | 8 | ## Translation into Objects 9 | - Parking Lot has Floors 10 | - Floors has slots 11 | - Slots has status (booked/available) 12 | - Vehicles will be parked in slots 13 | - Customer will have ticket with their vehicle registration on it 14 | - We need a slot booking service and update the empty slots inventory 15 | - Floors shall have empty slots so that to get empty slots in O1 time. 16 | - We need to have pricing strategy for slots 17 | 18 | ## Expected Queries 19 | - Free parking Slots of Particular Slot Type 20 | - is ParkingLot full 21 | 22 | ## Class Diagram Walk Through 23 | To be added 24 | 25 | 26 | ### ClassDiagram 27 | To be added 28 | 29 | ### Code 30 | [Code](https://github.com/LearningsLab/BoilerPlates/tree/main/ParkingLot) 31 | 32 | -------------------------------------------------------------------------------- /Splitwise/Repository/GroupRepository.java: -------------------------------------------------------------------------------- 1 | package Repository; 2 | 3 | import java.util.ArrayList; 4 | 5 | import models.Group; 6 | import models.User; 7 | 8 | 9 | 10 | public class GroupRepository implements IRepo { 11 | private ArrayList grpsRepo; 12 | private static GroupRepository groupRepo=null; 13 | 14 | public GroupRepository getInstance(){ 15 | if (grpsRepo==null){ 16 | GroupRepository groupRepo = new GroupRepository(); 17 | groupRepo.grpsRepo = new ArrayList(); 18 | } 19 | return groupRepo; 20 | } 21 | 22 | public Group addGroup(Group grp){ 23 | this.grpsRepo.add(grp); 24 | return this.grpsRepo.get(this.grpsRepo.size()-1); 25 | } 26 | 27 | public Group CreateGroup(User user){ 28 | ArrayList users = new ArrayList(); 29 | users.add(user); 30 | Group grp = new Group(users); 31 | 32 | return grp; 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ParkingLot/models/ParkingSlot.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class ParkingSlot { 4 | private int loc; 5 | private Boolean isBooked; 6 | private Boolean isActive; 7 | 8 | public int getLocation(){ 9 | return this.loc; 10 | } 11 | public Boolean setBooked(Boolean val){ 12 | this.isBooked=val; 13 | return this.isBooked; 14 | } 15 | public Boolean getBookedStatus(){ 16 | return this.isBooked; 17 | } 18 | 19 | public Boolean getStatus(){ 20 | return this.isActive; 21 | } 22 | public static class Builder{ 23 | private ParkingSlot pSlot; 24 | public Builder(){ 25 | this.pSlot=new ParkingSlot(); 26 | } 27 | public Builder addLoc(int no){ 28 | this.pSlot.loc=no; 29 | this.pSlot.isActive=true; 30 | return this; 31 | } 32 | public ParkingSlot buid(){ 33 | return this.pSlot; 34 | } 35 | 36 | } 37 | public static Object Builder() { 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /TaskPlanner/readme.md: -------------------------------------------------------------------------------- 1 | # Design a Task Planner 2 | 3 | ## Requirements 4 | - User shall be able to create Task , Bugs and Story 5 | - User shall be able to run a Sprint. 6 | - Different Status flow shall be maintained based on Task/Bug/Story. 7 | 8 | ## Translation into Objects 9 | - Task,bug and Story has attributes like start date,end date, AssignTo, Status, Description, Subject. 10 | - Task, Bug and Story may have a Sprint or a project or both. 11 | - Story can have tasks as well as bugs. 12 | - User will have a role like Admin and other roles are also posiible 13 | - Status Flow will have a predefined sequence to flow like for a task Coding to Coding to Testing is denied, Coding to Review and then Review to testing is allowed. 14 | 15 | 16 | ## Expected Queries 17 | - Sprint Tasks/Bugs/Stories with Filters like date/status/assignTo etc. 18 | - User Tasks/Bug/Stories with Filters 19 | 20 | ## Class Diagram Walk Through 21 | 1. Create an abstract class Tracker which contains common attributes for Task, Story and Bug 22 | 2. Using a Builder pattern to build a Task/Bug/Stroy 23 | 3. An Interface which maintains the ordered movement of status in task , bug and story. 24 | 25 | 26 | ### ClassDiagram 27 | [Link](https://github.com/LearningsLab/BoilerPlates/blob/main/TaskPlanner/TaskPlanner.drawio.png) 28 | 29 | 30 | ### Code 31 | [Link](https://github.com/LearningsLab/BoilerPlates/tree/main/TaskPlanner) 32 | 33 | ### [RepoWebLink](https://learningslab.github.io/BoilerPlates) -------------------------------------------------------------------------------- /CartService/readme.md: -------------------------------------------------------------------------------- 1 | # Design CartService 2 | 3 | # Requirements 4 | - User add products to cart. 5 | - Cart needs to show the total with any tax and subtotal.. as per the merchant 6 | - Cart needs to show if there is a coupon applied 7 | - Cart needs to show if orders are for different countires 8 | - Cart needs to show delivery channels alongwith order info 9 | - Cart needs to update quantities of products 10 | - Cart needs to delete addon products if main product is deleted 11 | - Cart need to be supported for different merchants 12 | - Requests needs to be validated 13 | 14 | ## Translation into Objects 15 | - Cart has a merchant id 16 | - Cart has products data and qty 17 | - Cart can have expiry date and status 18 | - Cart is linked to user session if not logged in 19 | - Cart is linked to user id if logged in 20 | - Cart will have methods to allow updation/deletion of products 21 | - Cart will have methods to show countrywise and delivery channelwise products 22 | - Cart will validate products 23 | - Cart will ask Bill Service to get subtotal and Tax 24 | - Middleware will validate the requests w.r.t session/tokens 25 | - Midlleware extract the merchant id request by decrypting the token and pass on information to controller 26 | 27 | ## Expected Queries 28 | - Cart will have queries on Product Models 29 | - Biiling Service will query Product Models + Prodcut_Taxation Models + Coupon Models 30 | - Middleware will query UserSession Models 31 | 32 | ## Class Diagram Walk Through 33 | To be added 34 | 35 | 36 | ### ClassDiagram 37 | To be added 38 | 39 | ### Code 40 | To be added 41 | 42 | -------------------------------------------------------------------------------- /SnakeLadder/readme.md: -------------------------------------------------------------------------------- 1 | # Design a Snake-Ladder Game 2 | 3 | ## Requirements 4 | - Players shall be able to play the game with snakes and ladder on a board having 100 cells. 5 | - Game ends when 1 player is left 6 | - Dice gives the number uniformly in any range. 7 | - 8 | ## Future Scope to add fishes in board 9 | - We may add fishes on board in future 10 | 11 | ## Translation into Objects 12 | - GAme has a Board,multiple Players and Dice. 13 | - Game has rules. 14 | - Game knows the turn of a player 15 | - Game has a winner 16 | - Board has cells. 17 | - cells may or may not have objects like snake/ladder/fishes. 18 | - Player has a symbl. 19 | - we can have an AiPlayer 20 | - We can have Human Players 21 | - Dice behavior has to be uniform for all the numbers being generated. 22 | 23 | ## Expected Queries 24 | - Whose turn? 25 | - To be added 26 | 27 | ## Class Diagram Walk Through 28 | 1. Board and cells need to be built. 29 | 2. Since cells are of different type we are using factory pattern to generate different cells. 30 | 3. Players are of different type we are using factory pattern to generate different players. 31 | 4. Building a player is done using builder pattern. 32 | 33 | 34 | ### ClassDiagram 35 | [Link](https://github.com/LearningsLab/BoilerPlates/blob/main/SnakeLadder/Snake%26Ladder.drawio.png) 36 | 37 | 38 | ### Code 39 | [Link](https://github.com/LearningsLab/BoilerPlates/tree/main/SnakeLadder) 40 | 41 | ### [RepoWebLink](https://learningslab.github.io/BoilerPlates) -------------------------------------------------------------------------------- /TicTacToe/Game.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.List; 3 | 4 | public class Game { 5 | private Board board; 6 | private int game_id; 7 | private String CurrMove; 8 | private List players; 9 | private Constants.GameStatus status; 10 | 11 | public Game(){ 12 | this.board=new Board(); 13 | this.players = new ArrayList<>(); 14 | } 15 | 16 | public int getGame_id(){ 17 | return this.game_id; 18 | } 19 | public Constants.GameStatus getStatus(){ 20 | return this.status; 21 | } 22 | public String getCurrMove(){ 23 | return this.CurrMove; 24 | } 25 | public List getPlayers(){ 26 | return this.players; 27 | } 28 | 29 | public Board getBoard(){ 30 | return this.board; 31 | } 32 | 33 | public static class Builder{ 34 | private Game game; 35 | public Builder(){ 36 | this.game = new Game(); 37 | } 38 | public Builder setBoardDimension(int rows,int cols) 39 | { 40 | ArrayList> localState=new ArrayList>(rows); 41 | for (int i = 0; i < cols; ++i) { 42 | localState.set(i, new ArrayList(cols)); 43 | } 44 | this.game.getBoard().setState(localState); 45 | return this; 46 | } 47 | public Builder addPlayer(Player player1){ 48 | this.game.players.add(player1); 49 | return this; 50 | } 51 | public Game build(){ 52 | return this.game; 53 | } 54 | 55 | } 56 | 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ParkingLot/models/client.java: -------------------------------------------------------------------------------- 1 | package models; 2 | import models.Constants.*; 3 | import services.BookingSlotService; 4 | public class client { 5 | public BookingSlotService bookingService; 6 | private static ParkStatus ParkVehicle(Vehicle vehicle,ParkingLot pLot){ 7 | Boolean isParkingLotFull=pLot.isFull(vehicle.getVehicleType()); 8 | 9 | if (isParkingLotFull){ 10 | return ParkStatus.FAIL; 11 | } 12 | 13 | // get empty slot and book it and return status 14 | 15 | ParkingSlot emptySlot=pLot.getFreeSlot(); 16 | Boolean status=emptySlot.setBooked(true); 17 | if (status){ 18 | return ParkStatus.SUCESS; 19 | } 20 | 21 | return ParkStatus.FAIL; 22 | } 23 | public static void main(String[] args) { 24 | 25 | //Create a ParkingLot 26 | //Add ParkingFloor to ParkingLot 27 | //Add Parking Slot to Parking Floor 28 | 29 | ParkingLot pLot= new ParkingLot.Builder("MALLROAD",5).addFloor(0,new 30 | ParkingFloor.Builder().addSlots(3,Constants.SlotOrVehicleTypes.CAR).buidFloor()).buidParkingLot(); 31 | // keep a list of available slots 32 | for (ParkingFloor floor:pLot.pFloors){ 33 | pLot.makeSlotsAvailbale(floor); 34 | } 35 | 36 | Vehicle car=new Vehicle(123,"HRBU7533",SlotOrVehicleTypes.CAR); 37 | 38 | ParkStatus parkStatus=ParkVehicle(car,pLot); 39 | if (parkStatus==ParkStatus.SUCESS){ 40 | System.out.println("VEhicle Parked Successfully"); 41 | System.out.println("Current parking inventory"+pLot.emptySlots()); 42 | } 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Splitwise/Controllers/UserController.java: -------------------------------------------------------------------------------- 1 | package Controllers; 2 | 3 | import models.Expense; 4 | import models.Group; 5 | import models.User; 6 | 7 | 8 | import Controllers.DTO.Response; 9 | import Services.UserService; 10 | 11 | public class UserController { 12 | private static UserController userController=null; 13 | private UserService userService; 14 | 15 | public UserController getInstance(){ 16 | if (userController==null){ 17 | UserController userController=new UserController(); 18 | //TODO 19 | // is this way correct to create service?? we dont need constructor function this way 20 | this.userController.userService = new UserService(); 21 | 22 | } 23 | return userController; 24 | } 25 | public Group createGrp(User user){ 26 | return userController.userService.createGrp(user); 27 | } 28 | public Response letsSettle(User user, Group grp){ 29 | Boolean status = userController.userService.isMemberofGroup(user,grp); 30 | if (status) { 31 | userController.userService.askToSettle(user, grp); 32 | return new Response(status,"Settled","200"); 33 | } 34 | return new Response(status,"user not part of Group","400"); 35 | } 36 | public Response addExpense(Group grp,Expense expense){ 37 | userController.userService.addExpense(grp, expense); 38 | 39 | //update the net balance for users in the group. this will help in faster settling up 40 | grp.setmembersNetBal(userService.updUserNetBal(expense, grp)); 41 | //TODO 42 | //shall I call grp method as abv or it shall be thru some service?? 43 | 44 | return new Response(true, "expense added", "200"); 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Splitwise/models/Group.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Map; 5 | 6 | public class Group extends BaseModel { 7 | private ArrayList members; 8 | private ArrayList expenses; 9 | private ArrayList txns; 10 | private Boolean isSetteled; 11 | private ArrayList adminUsers; // only 1 admin user supported 12 | private Map membersNetBal; 13 | 14 | public Group (ArrayList grpMembers){ 15 | this.members=grpMembers; 16 | this.adminUsers=grpMembers; 17 | this.expenses = new ArrayList(); 18 | this.txns = new ArrayList(); 19 | } 20 | public ArrayList getAdminUsers(){ 21 | return this.adminUsers; 22 | } 23 | public ArrayListgetUsers(){ 24 | return this.members; 25 | } 26 | public void setmembersNetBal(Map usersNetBal){ 27 | this.membersNetBal=usersNetBal; 28 | return; 29 | } 30 | public Map getMembersNetBal() { 31 | return membersNetBal; 32 | } 33 | public ArrayList getexpenses(){ 34 | return this.expenses; 35 | } 36 | public ArrayList getGrpMembers(){ 37 | return this.members; 38 | } 39 | public ArrayList getTxns(){ 40 | return this.txns; 41 | } 42 | public Boolean isSettled(){ 43 | return this.isSetteled; 44 | } 45 | public Boolean setSettled(){ 46 | this.isSetteled=true; 47 | return this.isSetteled; 48 | } 49 | public Expense addExpense(Expense expense){ 50 | this.expenses.add(expense); 51 | return this.expenses.get(this.expenses.size()-1); 52 | } 53 | public ArrayList adduser(User u){ 54 | this.members.add(u); 55 | this.membersNetBal.put(u,0f); // update grp member net balance 56 | return this.members; 57 | } 58 | 59 | 60 | 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Splitwise/models/Expense.java: -------------------------------------------------------------------------------- 1 | package models; 2 | import java.util.Map; 3 | import java.util.ArrayList; 4 | import models.BaseModel; 5 | import Config.Constants; 6 | 7 | public class Expense extends BaseModel{ 8 | 9 | private Map contributors; 10 | private Float amt; 11 | private Map payees; 12 | private Constants.SplitStrategy splitStrategy; 13 | private Group grp; 14 | private User creator; 15 | private User admin; 16 | 17 | public Float getExpenseAmt(){ 18 | return this.amt; 19 | } 20 | public Map getContributors(){ 21 | return this.contributors; 22 | } 23 | public Map getPayees(){ 24 | return this.payees; 25 | } 26 | public Constants.SplitStrategy getSplitStrategy(){ 27 | return this.splitStrategy; 28 | } 29 | public Group getExpenseGrp(){ 30 | return this.grp; 31 | } 32 | public User getAdmin() { 33 | return admin; 34 | } 35 | public User getCreator() { 36 | return creator; 37 | } 38 | public Float getAmt() { 39 | return amt; 40 | } 41 | public Group getGrp() { 42 | return grp; 43 | } 44 | 45 | public static class Builder{ 46 | private Expense expense; 47 | public Builder(User user){ 48 | this.expense = new Expense(); 49 | this.expense.creator = user; 50 | } 51 | 52 | public Builder setAmt(Float amt){ 53 | this.expense.amt=amt; 54 | return this; 55 | } 56 | 57 | public Builder setContributors(Map contribs){ 58 | this.expense.contributors=contribs; 59 | return this; 60 | } 61 | 62 | public Builder setpayees(Map borrowers){ 63 | this.expense.payees=borrowers; 64 | return this; 65 | } 66 | 67 | public Expense buildExpense(){ 68 | return this.expense; 69 | } 70 | 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Splitwise/client.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | 5 | import Controllers.GroupController; 6 | import Controllers.UserController; 7 | import Services.GroupService; 8 | import Services.UserService; 9 | import models.Expense; 10 | import models.Group; 11 | import models.User; 12 | 13 | public class client { 14 | public static void main() { 15 | // add users 16 | // create grp 17 | // add user in grp 18 | // add expenses in grp 19 | // settle expenses 20 | 21 | User u1 = new User("email1@gmail.com", "manish", "9953215581"); 22 | User u2 = new User("email2@gmail.com", "hawan", "9953215582"); 23 | User u3 = new User("email3@gmail.com", "pawan", "9953215580"); 24 | ArrayList users=new ArrayList<>(); 25 | users.add(u1); 26 | users.add(u2); 27 | 28 | //u1 creates grp 29 | 30 | GroupController grpController = new GroupController(); 31 | Group grp1 = grpController.CreatetGrp(u1); 32 | grp1.adduser(u3); 33 | 34 | //contributors 35 | Map contribs=new HashMap(); 36 | contribs.put(u1,300.0f); 37 | contribs.put(u2,700.0f); 38 | Map receivers = new HashMap(); 39 | receivers.put(u3,100f); 40 | 41 | 42 | //create expense 43 | Expense expense = new Expense.Builder(u1).setContributors(contribs).setpayees(receivers).setAmt(1000.0f).buildExpense(); 44 | grp1.addExpense(expense); 45 | //add new expense 46 | contribs.clear(); 47 | receivers.clear(); 48 | contribs.put(u1,1000.0f); 49 | 50 | receivers.put(u3,300f); 51 | receivers.put(u2,300f); 52 | Expense expense1 = new Expense.Builder(u1).setContributors(contribs).setpayees(receivers).setAmt(1000.0f).buildExpense(); 53 | grp1.addExpense(expense1); 54 | 55 | grpController.getgrpService().settleup(grp1); 56 | //groupService.settleup(grp1); 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Splitwise/Services/GroupService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import java.security.PublicKey; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.Collections; 7 | import java.util.Map; 8 | 9 | import Repository.GroupRepository; 10 | import models.Group; 11 | import models.Txn; 12 | import models.User; 13 | 14 | public class GroupService { 15 | private static GroupService grpService=null; 16 | private GroupRepository grpRepo; 17 | public static GroupService getInstance(){ 18 | if (grpService==null){ 19 | grpService=new GroupService(); 20 | GroupRepository grpRepo = new GroupRepository(); 21 | } 22 | return grpService; 23 | 24 | } 25 | 26 | public Boolean settleup(Group grp){ 27 | //Todo 28 | //Code To be added here 29 | // get grp expenses list 30 | // accumulate as per the users 31 | // make transaction summary and print it. 32 | // Map usersNetBalance = cummulateExpenses(); 33 | Map usersNetBalance = grp.getMembersNetBal(); 34 | ArrayList payers= new ArrayList<>(); 35 | ArrayList receivers= new ArrayList<>(); 36 | 37 | ArrayList txns =new ArrayList<>(); 38 | 39 | txns= offsetTxns(payers, receivers, txns); 40 | 41 | //update the txns 42 | TxnService txnService = new TxnService(); 43 | txnService.addTxns(txns); 44 | 45 | // minTxns=getMinTxns(); 46 | grp.setSettled(); 47 | return true; 48 | } 49 | public Group createGrp(User user){ 50 | Group grp=this.grpRepo.CreateGroup(user); 51 | return grp; 52 | } 53 | private ArrayList offsetTxns(ArrayList payers,ArrayList receivers,ArrayList txns){ 54 | // get max payer from the payers list 55 | //User maxPayer= Collections.max(payers); 56 | 57 | 58 | //get max from the receivers list 59 | 60 | //offset the maxs and repeat 61 | 62 | return txns; 63 | } 64 | // public ArrayList getExpenseList(){ 65 | 66 | // } 67 | 68 | // public Map cummulateExpenses(){ 69 | 70 | // } 71 | // public addExpense(){ 72 | 73 | // } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BoilerPlates 2 | _This repo only contains the Low Level designs for given requirements_ 3 | 4 | ## Web Link 5 | https://learningslab.github.io/BoilerPlates/ 6 | 7 | ## Few Designs Included 8 | - Design a Task Planner 9 | - Class Diagram 10 | - Boiler Plate Code 11 | - Design a Snake and Ladder 12 | - ClassDiagram 13 | - Boiler Plate Code 14 | - Design a Parking Lot 15 | - Boiler Plate Code 16 | - Working Code 17 | - Design Splitwise 18 | - Boiler Plate Code 19 | - Design a Login library 20 | - Boiler Plate Code 21 | 22 | ## To be added 23 | - Design a Delivery Route Service for Warehouses/Kitchens 24 | - Design a Subscription Service 25 | - Design a Tic Tac Toe 26 | - Design a Chess Game 27 | - Design Google Photos 28 | - Design Data Migrator Tool 29 | - Design a Job Scheduler 30 | - Design a Web Crawler 31 | 32 | 33 | ## Common Design Pattern Use Cases 34 | 35 | ### Adapter Design Pattern 36 | - It combines the two incompatible interfaces/components so that client or other code changes can be avoided 37 | 38 | ### Builder Design Pattern 39 | - When we have multiple attributes which can just explode the no of constructors of that class. Using Builder Pattern we can just create the immutable object. 40 | 41 | ### Factory Design Pattern 42 | - when we need to create different types of objects in the application. Factory pattern helps in organising the code 43 | 44 | ### Fly Weight Design Pattern 45 | 46 | ### Singleton Design Pattern 47 | - when we just need to have single object of the class thoughtout the application 48 | 49 | ### Decorator Design Pattern 50 | 51 | ### Strategy Design Pattern 52 | 53 | ### Prototype Design Pattern 54 | 55 | ### Proxy Design Pattern 56 | 57 | 58 | 59 | # Want to Contribute ?? 60 | 61 | ### Add/Update a Design Problem 62 | - Goto Branch _gh-pages_ 63 | - Create a _md_ file of the problem 64 | - Add Different sections Like 65 | - Requirements 66 | - Transaltion to Model/Services 67 | - Use Case Diagram 68 | - Class Diagram 69 | - Code Link 70 | - Design Trade Offs 71 | - Raise the PR for _gh-pages_ branch 72 | 73 | ### Add/Update a Diagram/Code 74 | - Goto Branch _main_ 75 | - Goto Directory of the design problem 76 | - Add the class diagram for the requirements given for the problem in _gh-pages_ branch 77 | - Raise the PR for _main_ branch 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /ParkingLot/models/ParkingFloor.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | //import java.util.List; 4 | import java.util.Map; 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | 8 | //import models.Constants.SlotOrVehicleTypes; 9 | 10 | public class ParkingFloor { 11 | Map> pSlots; 12 | ArrayList parkingSlots; 13 | //private int maxSlots; 14 | private int lastSlotNo=0; 15 | 16 | 17 | public Boolean isFull(){ 18 | if (this.pSlots.size()==Constants.MaxSlotsPerFloor){ 19 | return true; 20 | } 21 | return false; 22 | } 23 | 24 | public static class Builder { 25 | private ParkingFloor pFloor; 26 | 27 | public Builder(){ 28 | this.pFloor=new ParkingFloor(); 29 | this.pFloor.pSlots=new HashMap>(); 30 | this.pFloor.parkingSlots = new ArrayList<>(); 31 | } 32 | 33 | public Builder addSlots(int no,Constants.SlotOrVehicleTypes type){ 34 | //throw exception if parking slot capacity is exceeding 35 | //System.out.println("parkingfloor "+this.pFloor.pSlots); 36 | if (no+this.pFloor.pSlots.size()>=Constants.MaxSlotsPerFloor){ 37 | 38 | System.out.println("parking Floor can only add"+ (Constants.MaxSlotsPerFloor-this.pFloor.pSlots.size())+ "slots"); 39 | } 40 | 41 | for (int i=0;i tmp=new ArrayList(); 45 | if (this.pFloor.pSlots.get(type)!=null){ 46 | tmp = this.pFloor.pSlots.get(type); 47 | } 48 | 49 | System.out.println("tmp value"+tmp); 50 | tmp.add(newSlot); 51 | this.pFloor.pSlots.put(type,tmp); 52 | this.pFloor.parkingSlots.add(newSlot); 53 | } 54 | 55 | return this; 56 | } 57 | public ParkingFloor buidFloor(){ 58 | return this.pFloor; 59 | } 60 | 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /ParkingLot/models/ParkingLot.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | 4 | import java.util.ArrayList; 5 | // import java.util.HashMap; 6 | // import java.util.Map; 7 | //import java.util.Currency; 8 | //import java.util.Map; 9 | import java.util.Stack; 10 | 11 | public class ParkingLot{ 12 | 13 | private String name; 14 | ArrayList pFloors; 15 | //Map> mapSlots; 16 | private Stack emptySlots; 17 | private int maxFloors; 18 | 19 | public ParkingLot(String name,int floors){ 20 | this.emptySlots=new Stack<>(); 21 | this.maxFloors=floors; 22 | this.name=name; 23 | } 24 | 25 | public String getLocation(){ 26 | return this.name; 27 | } 28 | public Boolean isFull(Constants.SlotOrVehicleTypes stype){ 29 | for (ParkingFloor floor:this.pFloors){ 30 | ArrayList slots=floor.pSlots.get(stype); 31 | if (slots.size()>0){ 32 | return false; 33 | } 34 | } 35 | return true; 36 | } 37 | public Boolean makeSlotsAvailbale(ParkingFloor floor){ 38 | for ( ParkingSlot slot : floor.parkingSlots) { 39 | this.emptySlots.add(slot); 40 | } 41 | return true; 42 | } 43 | 44 | public ParkingSlot getFreeSlot(){ 45 | return this.emptySlots.pop(); 46 | } 47 | public int emptySlots(){ 48 | return this.emptySlots.size(); 49 | } 50 | 51 | public static class Builder{ 52 | private ParkingLot pLot; 53 | public Builder(String name,int floors){ 54 | this.pLot=new ParkingLot(name,floors); 55 | this.pLot.pFloors= new ArrayList<>(); 56 | this.pLot.emptySlots = new Stack(); 57 | //this.pLot.mapSlots = new HashMap<>(); 58 | } 59 | public Builder setName(String name){ 60 | this.pLot.name=name; 61 | return this; 62 | } 63 | public Builder addFloor(int no,ParkingFloor pFloor){ 64 | if (this.pLot.pFloors.size()==this.pLot.maxFloors){ 65 | System.out.println("reached max no already "); 66 | } 67 | this.pLot.pFloors.add(pFloor); 68 | return this; 69 | } 70 | 71 | public ParkingLot buidParkingLot(){ 72 | return this.pLot; 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /LoginPackage/LoginManager: -------------------------------------------------------------------------------- 1 | 7V1tc5s4EP41nul9SAfxZviYuE17M+1N59K5l4+ykW2mGPkwbpL++pOwwCCJmLhg1GQzmYlZC4F2H3aflVZk4sw2Dx8yvF1/phFJJrYVPUycdxPbRq4VsD9c8niQTF0hWGVxJBodBXfxDyKElpDu44jsGg1zSpM83jaFC5qmZJE3ZDjL6H2z2ZImzatu8YoogrsFTlTp33GUrw/SwLOO8o8kXq3LKyNLfDPHi2+rjO5Tcb2UpuTwzQaX3YimuzWO6H1N5LyfOLOM0vzwafMwIwlXa6mxw3m3Ld9Wt5yRNO90whQv5thjpiGeE/rzK9HDd5zshRqWGd6I29/lj6Vy2I1v+cf9JrktGjg39+s4J3dbvODye4YJJlvnm4QdIfaxUAjh17XYUTVwfrCgm3ghPid4TpKbSoMzmtCMfVXokJ2WZ/RbZQ7e7ZKm+S3exAlH2V8ki3CKhVhACvFucRKvUnawYIohrMMbVVPl0EmWk4eaSGjuA6EbkmePrIn4tjTiY/PwvgaWUrauA8XyhRQLhK6qro+mYh+EtfSW8yIbhd48CqwILxFCV06gGIlEDNDikGb5mq5oipP3R6lklJq1IrxbF3LUwSY4y29jfqdFLySNrvnjxy+6JelB0vy+bpmOBmy1147us0X5yMpwtoXfwNmK5C2KCw9tuLKetHpGEpzH35veQWfC4lSmAvxYa7ClcZrvaj1/4YIjmLywiaapuMIRDocej+Cobu08vLgW4OUsvKAL46XhEZ5n9Lbx1dz7LMG7Xap18ffxJsGFyWqGLvQsGhW+ex0n0Sf8SPdcX8y2i2/l0c2aZvEP1h6XJxemF1ayfd4bM7MEj+NJd7wzcZmM7NhpX0pzokr0Ce/yKowkCd7u4nlxc7zJhtkxTm9ontNNGXjEqG5rV57YzrL4eZFhyveansW3AyVQIV8XqAL/5+OUAkFHgeDEvuH8LCacoF3zx+9xq8KRjTZvQvGgZUn1GkSVSk3IkvfANRczmnctxDnlTGXHiEucrj4Vbd65R8mfQiFuC8WhrL9lUoBkHUdR4cAymuMcz6uHRDzMbBzeDftlup5Zb72Jx8Y1Y8foeMx+efMsn9GUjQ/HhdkJA/k94UDXAaLtIT+NkJK5+N0AYQ+BBxfwYBoePHtEPPiAB9PwMO0YMAbBQwh4MA0PyHJHBEQ5PwSIMAgRjjr5cTlEBAAI4wDhjckpbdVFQJ770vNcR8pz3Y4sFqEepmNVCKoz6eCUenZKVmeImJDo2pDpmoeIUVNdG3Jd8xAxarLrAHF5fcTFC5rEJZiOSVwcIC5DOyXn1yIujrpqCIgYGxGjEhcHFvHMQ8SoxMVVkxsgLi+duMiVBWFXCAbOEBD0wCkN7JSqp/zXIC7uFBBhHCIuSVzUItlQsfWrK3psK2isFz222rm/qsezbajmp8A0XhvTCJyuNYx9zJEoEISEuOe40vqQG0k01LACeDAND6PSDFjpMw4Pl5wdUfGAFFMD7fQ60E67b9Y53F6btvEBT33FPNXTbAodbEZMQSCUFwwdhrzOADGBpsJ0mHF4GJWm6uqmfbzZFj73vz1lf2PuG5dc6+U3mfiGCRKulXnGPq3yuqQU/FGEuoOQ3dz82FAC2It+TYAr7exGlm77BNIY3Rti7sLxgIu2vQPgyX3fwYW5qOhZfk9AucxVrblJb/h4Xvv+3yvg+ICvs/CFHDMA1kJhBwOMboPfIWZsGzDyWdzJq0SD0RVr+1AdXhVU4totRJyvXAlXfl1z5WUPcsCKawIR/tSj35VI2Dyl0SNTQqyExYwrsS1W1rvXBMxKtpVl64xrqXx7UjlEVB+tctXnKPZA3YRmdTqsGCQ6UMivBYXUjrlqaqtNjR0bw/aaRugNv9nfOg3xcIb95tBsJk7QnNscs+Q19WRZYtQ1CrwsXFvDYdmyX/tIku+E99r0soOQrh6YE2rGrsB2VOIU6lZ93CGYk3bjKXgq8FSmjA081VieSt576E01ef3lPJXjAgdX3bemzsXQJM9F8pSBHT6Z5Z06oX/WXmoTgiEEQyPHBsFwrGCIpAnP0NKsvV+QttvgqcBTGTw28FSmeKqpq1mZuaCn0tURwoJc7y+KkfZbu6GnWv1i63FIVywIRh/c6GUXoxjdhkUyzZOgqQhUG00vnKH3WRKIdFsUgYoCFTVlbEBFR1vrkmaQbd0bNS9IRdXa0a+8ClA2nFoaWJQKtxbg8Ro7vM+pADpSrfxkjeBXfvDuytXEnCdCU6322Cp++qEUsslcT80eXJ3FBjGYrrgTaGTvBd5Bc0nano6ZO1S0qhcaaQJzbFDZM2lkoNLI1vfCGbCf2bb7NCJ5iPN/ap//5U3eMpS+nDShi32d3u17XjGd0wwRKLTrWDnd3rUlbPW9jKetAYeMBDISQ8YGGclYGYnfdEW6t1JeLh8pK/9gwqzuvDVl5RdgOmdFQkf+b5nh0/sW5PZo6DJ0G2qmzkSYIVxLrsFz0AmEyTMuJ9rLGyOe277c1zccgmFnVzcEt87Lj43gqYRg9wSC5fbW0Aib9omwV5CqdgJf769W6yVAO2Jmq2uAdt2BwVcqE1JVSFWNHBukqoakqnYZF0fKVQPgYapSrF83FLrPzFXdwZk+vMb2XIT1vsn+/E1aFhjxTCMaMuFgSZv+ghNuQmrvD724U/4rH0DYcxFmyHyAvKvUPwGwp9sPALBel65fE8DKTUkjIwxJM0jTYGjEwDrOuYhBZiDGbSKm/J8vw3FdeOsGTPuYPDaY9jFk2qeqxx3ppRu9Lo68kNDWZUtPaERg8yQq5IU/RYXYYUa5tzg2z/B2/ZlGhLf4Hw== -------------------------------------------------------------------------------- /Splitwise/Services/UserService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | import models.Expense; 10 | import models.Group; 11 | import models.User; 12 | import models.Pair; 13 | import models.Txn; 14 | 15 | public class UserService { 16 | private static UserService userService=null; 17 | 18 | public static UserService getInstance(){ 19 | if (userService==null){ 20 | UserService userService = new UserService(); 21 | } 22 | return userService; 23 | } 24 | public Group createGrp(User user){ 25 | //TODO 26 | // shall I create a grp in User service w/o asking grp service? 27 | ArrayList users=new ArrayList<>(); 28 | Group grp = new Group(users); 29 | return grp; 30 | } 31 | 32 | public Expense addExpense(Group grp,Expense expense){ 33 | return grp.addExpense(expense); 34 | } 35 | 36 | public String askToSettle(User reqUser,Group grp){ 37 | //TODO 38 | // Calculate the net balance for each user 39 | // greedily offset the txns 40 | // update the Txns for each user 41 | Map userNetBal= grp.getMembersNetBal(); 42 | ArrayList creditors = new ArrayList(); 43 | ArrayList borrowers = new ArrayList(); 44 | 45 | for(User user: grp.getGrpMembers()){ 46 | if (userNetBal.getOrDefault(user, 0f)<0){ 47 | Pair obj =new Pair<>(user,userNetBal.get(user)); 48 | borrowers.add(obj); 49 | } 50 | else if(userNetBal.getOrDefault(user, 0f)>0){ 51 | Pair obj =new Pair<>(user,userNetBal.get(user)); 52 | creditors.add(obj); 53 | } 54 | ArrayList txns=getminTxns(creditors,borrowers); 55 | //TODO 56 | // get Txns object from algo 57 | //update the Txn model 58 | TxnService txnService = new TxnService(); 59 | //save the txn object in txns Rerpo 60 | // shall Txn model have the ArrayList? 61 | 62 | } 63 | 64 | //aply greedy algo to get txns 65 | 66 | // get expenses list 67 | // calculate the net balance for each user 68 | // calc 69 | 70 | return "fail"; 71 | } 72 | 73 | public ArrayList getminTxns(ArrayList creditors,ArrayList borrowers){ 74 | ArrayList txns=new ArrayList(); 75 | 76 | return txns; 77 | 78 | } 79 | 80 | public Boolean isMemberofGroup(User user, Group grp){ 81 | if (grp.getUsers().contains(user)){ 82 | return true; 83 | } 84 | return false; 85 | } 86 | public Map updUserNetBal(Expense expense,Group grp){ 87 | // ToDo 88 | // get share of each user 89 | // update the net balnce of participants in grp 90 | //return the object 91 | Map contribs = expense.getContributors(); 92 | Map receivers = expense.getPayees(); 93 | 94 | Map usersNetBal = grp.getMembersNetBal(); 95 | 96 | 97 | ArrayList members = grp.getGrpMembers(); 98 | for (User user : members) { 99 | usersNetBal.put(user,usersNetBal.get(user)+contribs.getOrDefault(user,0f) 100 | -receivers.getOrDefault(user, 0f)); 101 | } 102 | 103 | return usersNetBal; 104 | 105 | } 106 | 107 | 108 | 109 | 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Splitwise/readme.md: -------------------------------------------------------------------------------- 1 | ### Design Splitwise 2 | 3 | ## Requirements 4 | 5 | - Users can register and update their profiles 6 | - A user's profile should contain at least their name, phone number and password 7 | - Users can participate in expenses with other users 8 | - Users can participate in groups. 9 | - To add an expense, a user must specify either the group, or the other users involved in the expense, along with who paid 10 | what and who owes what. They must also specify a description for the expense. 11 | - A user can see their total owed amount 12 | - A user can see a history of the expenses they're involved in 13 | - A user can see a history of the expenses made in a group that they're participating in 14 | - Users shouldn't be able to query about groups they are not a member of 15 | - Only the user who has created a group can add/remove members to the group 16 | - Users can request a settle-up. The application should show a list of transactions, which when executed will ensure that 17 | the user no longer owes or recieves money from any other user. Note that this need not settle-up any other users. 18 | - Users can request a settle-up for any group they're participating in. The application should show a list of transactions, 19 | which if executed, will ensure that everyone participating in the group is settled up (owes a net of 0 Rs). Note that will 20 | only deal with the expenses made inside that group. Expenses outside the group need not be settled. 21 | Good to Have Requirements 22 | - When settling a group, we should try to minimize the number of transactions that the group members should make to 23 | settle up. 24 | 25 | Note: All tests will be performed in one go. The application doesn't need to persist data between runs. 26 | 27 | ## Input Format 28 | 29 | 30 | Register vinsmokesanji 003 namisswwaann 31 | 32 | > u1 is registering with the username "vinsmokesanji", phone "003" and password as "namisswwaann" 33 | -- -- 34 | u1 UpdateProfile robinchwan 35 | 36 | > u1 is updating their profile password to "robinchwan" 37 | -- -- 38 | u1 AddGroup Roommates 39 | 40 | > u1 is creating a group titled "Roommates" 41 | -- -- 42 | u1 AddMember g1 u2 43 | 44 | > u1 is adding u2 as a member of the group "Roommates" (which has the id g1) 45 | -- -- 46 | u1 MyTotal 47 | > u1 is asking to see the total amount they owe/recieve after everything is settled. 48 | -- -- 49 | u1 History 50 | > u1 is asking to see their history of transactions (whether added by themselves or someone 51 | else) 52 | -- -- 53 | u1 Groups 54 | > u1 is asking to see the groups that they're a member of 55 | -- -- 56 | u1 SettleUp 57 | > u1 is asking to see the list of transactions they should perform to settle up 58 | -- -- 59 | u1 SettleUp g1 60 | > u1 is asking to see the list of transactions that need to be performed by members of g1 to 61 | completely settle up the group. 62 | -- -- 63 | u1 Expense g1 iPay 1000 Equal Desc Wifi Bill 64 | > u1 is adding an expense in the group g1. 65 | > u1 paid 1000 Rs 66 | > each user of g1 owes an equal amount (the exact amount will depend on the number of users in group g1. Say g1 has 5 67 | users, then the amount owed by each will be 200Rs). 68 | -- -- 69 | u1 Expense u2 u3 u4 iPay 1000 Equal Desc Last night dinner 70 | > u1 is adding an expense with users u2, u3 and u4. 71 | > u1 paid 1000 Rs 72 | > each user owes an equal amount - 250Rs. 73 | -- -- 74 | u1 Expense u2 u3 iPay 1000 Percent 20 30 50 Desc House rent 75 | > u1 is adding an expense with users u2 and u3 76 | > u1 paid 1000 Rs 77 | > u1 owes 20% (200Rs), u2 owes 30% (300Rs) and u3 owes 50% (500Rs). 78 | -- -- 79 | u1 Expense u2 u3 u4 iPay 1000 Ratio 1 2 3 4 Desc Goa trip 80 | > u1 is adding an expense with users u2, u3 and u4. 81 | > u1 paid 1000 Rs 82 | > u1 owes 100Rs (1 part), u2 owes 200Rs (2 parts), u3 owes 300Rs (3 parts) and u4 owes 400Rs (4 83 | parts). 84 | -- -- 85 | u1 Expense u2 u3 iPay 1000 Exact 100 300 600 Desc Groceries 86 | > u1 is adding an expense with users u2 and u3. 87 | > u1 paid 1000 Rs 88 | > u1 owes 100Rs, u2 owes 300Rs and u3 owes 600Rs. 89 | -- -- 90 | u1 Expense u2 u3 MultiPay 100 300 200 Equal Desc Lunch at office 91 | > u1 is adding an expense with users u2 and u3. 92 | > u1 paid 100 Rs, u2 paid 300Rs and u3 paid 200Rs. 93 | > Each user owes an equal amount - 200Rs. 94 | -- -- 95 | u1 Expense u2 u3 MultiPay 500 300 200 Percent 20 30 50 Desc Netflix subscription 96 | > u1 is adding an expense with users u2 and u3. 97 | > u1 paid 500 Rs, u2 paid 300Rs and u3 paid 200Rs. 98 | > u1 owes 20% (200Rs), u2 owes 30% (300Rs) and u3 owes 50% (500Rs). 99 | 100 | -- -- 101 | reference from https://github.com/Naman-Bhalla/splitwise -------------------------------------------------------------------------------- /Splitwise/Splitwise.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /TaskPlanner/TaskPlanner.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /SnakeLadder/Snake&Ladder.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | --------------------------------------------------------------------------------