From 7acbb5a84220876670bfb8ce782dc2487e6363e2 Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Sun, 2 Feb 2025 22:28:46 +0530 Subject: [PATCH 1/7] solved snake and ladder implementation --- snakeAndLadder/pom.xml | 30 +++ .../src/main/java/org/machinecoding/Main.java | 49 +++++ .../java/org/machinecoding/models/Board.java | 7 + .../org/machinecoding/models/BoardEntity.java | 54 +++++ .../java/org/machinecoding/models/Dice.java | 7 + .../java/org/machinecoding/models/Player.java | 29 +++ .../models/teleports/Ladder.java | 7 + .../machinecoding/models/teleports/Snake.java | 7 + .../models/teleports/Teleporter.java | 6 + .../models/teleports/TeleporterEntity.java | 29 +++ .../strategy/DiceMovementStrategy.java | 22 ++ .../strategy/GameMovementStrategy.java | 34 +++ .../strategy/MovementStrategy.java | 6 + .../strategy/TeleporterMovementStrategy.java | 37 ++++ .../strategy/GameMovementStrategyTest.java | 202 ++++++++++++++++++ .../target/machineCoding-1.0-SNAPSHOT.jar | Bin 0 -> 11157 bytes .../target/maven-archiver/pom.properties | 3 + .../compile/default-compile/createdFiles.lst | 13 ++ .../compile/default-compile/inputFiles.lst | 13 ++ .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 + 21 files changed, 556 insertions(+) create mode 100644 snakeAndLadder/pom.xml create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/Main.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Board.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Player.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java create mode 100644 snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java create mode 100644 snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar create mode 100644 snakeAndLadder/target/maven-archiver/pom.properties create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/snakeAndLadder/pom.xml b/snakeAndLadder/pom.xml new file mode 100644 index 00000000..424f86a0 --- /dev/null +++ b/snakeAndLadder/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.machinecoding + snakeAndLadder + 1.0-SNAPSHOT + + + 23 + 23 + UTF-8 + + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + org.mockito + mockito-core + 4.0.0 + test + + + diff --git a/snakeAndLadder/src/main/java/org/machinecoding/Main.java b/snakeAndLadder/src/main/java/org/machinecoding/Main.java new file mode 100644 index 00000000..430d4645 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/Main.java @@ -0,0 +1,49 @@ +package org.machinecoding; + +import org.machinecoding.models.Board; +import org.machinecoding.models.BoardEntity; +import org.machinecoding.models.Dice; +import org.machinecoding.models.Player; +import org.machinecoding.models.teleports.Ladder; +import org.machinecoding.models.teleports.Snake; +import org.machinecoding.models.teleports.TeleporterEntity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int targetCell = 100; + + int numSnakes = scan.nextInt(); + List teleporterList = new ArrayList<>(); + for (int i = 0; i < numSnakes; i++) + teleporterList.add(new Snake(scan.nextInt(), scan.nextInt())); + + int numLadder = scan.nextInt(); + for (int i = 0; i < numLadder; i++) + teleporterList.add(new Ladder(scan.nextInt(), scan.nextInt())); + + int numPlayers = scan.nextInt(); + List playerList = new ArrayList<>(); + for (int i = 0; i < numPlayers; i++) + playerList.add(new Player(scan.next(), 0, targetCell)); + + // debug +// for (TeleporterEntity teleporter : teleporterList) +// System.out.println("start: " + teleporter.getStartCell() + +// ", end: " + teleporter.getEndCell()); +// +// for (Player player : playerList) +// System.out.println(player.getName() + " is at " + player.getPosition()); + + List diceList = new ArrayList<>(); + diceList.add(new Dice()); + + BoardEntity boardEntity = new BoardEntity(new Board(targetCell), + teleporterList, playerList, diceList); + boardEntity.start(); + } +} \ No newline at end of file diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java new file mode 100644 index 00000000..64f66bf8 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java @@ -0,0 +1,7 @@ +package org.machinecoding.models; + +public class Board { + private int cells; + + public Board(int cells) { this.cells = cells; } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java b/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java new file mode 100644 index 00000000..9efb7a13 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java @@ -0,0 +1,54 @@ +package org.machinecoding.models; + +import org.machinecoding.models.teleports.TeleporterEntity; +import org.machinecoding.strategy.DiceMovementStrategy; +import org.machinecoding.strategy.GameMovementStrategy; +import org.machinecoding.strategy.TeleporterMovementStrategy; + +import java.util.List; + +public class BoardEntity { + private final Board board; + private final List teleports; + private final List players; + private final List dices; + + private GameMovementStrategy movementStrategy; + + public BoardEntity(Board board, List teleports, List players, List dices) { + this.board = board; + this.teleports = teleports; + this.players = players; + this.dices = dices; + + this.movementStrategy = new GameMovementStrategy(new DiceMovementStrategy(dices), new TeleporterMovementStrategy(teleports)); + } + + public void start() { + while(shouldPerformRound()){ + performOneRound(); + } + } + + private boolean shouldPerformRound() { + return players.stream().filter(p -> !p.isWinner()).count() > 1; + } + + public void performOneRound(){ + for (Player player : players) { + if(!shouldPerformRound()) return; + + int currentPosition = player.getPosition(); + int newPosition = movementStrategy.move(currentPosition); + player.move(newPosition); + + System.out.println(player.getName() + " rolled a " + movementStrategy.getDiceValue() + " and moved from " + + currentPosition + " to " + player.getPosition()); + + if (player.isWinner()) { + System.out.println(player.getName() + " wins the game"); + } + } + } +} + diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java new file mode 100644 index 00000000..c8aba8dd --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java @@ -0,0 +1,7 @@ +package org.machinecoding.models; + +public class Dice { + public int roll() { + return (int) (Math.random() * 6) + 1; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java new file mode 100644 index 00000000..b9f54f75 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java @@ -0,0 +1,29 @@ +package org.machinecoding.models; + +public class Player { + private final String name; + private int position; + private final int targetPosition; + + public Player(String name, int startPosition, int targetPosition){ + this.name = name; + this.position = startPosition; + this.targetPosition = targetPosition; + } + + public void move(int newPosition){ + this.position = (newPosition > targetPosition) ? position : newPosition; + } + + public boolean isWinner(){ + return (position == targetPosition); + } + + public int getPosition(){ + return position; + } + + public String getName(){ + return name; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java new file mode 100644 index 00000000..896afcee --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java @@ -0,0 +1,7 @@ +package org.machinecoding.models.teleports; + +public class Ladder extends TeleporterEntity { + public Ladder(int startCell, int endCell) { + super(startCell, endCell); + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java new file mode 100644 index 00000000..63f45446 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java @@ -0,0 +1,7 @@ +package org.machinecoding.models.teleports; + +public class Snake extends TeleporterEntity { + public Snake(int startCell, int endCell) { + super(startCell, endCell); + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java new file mode 100644 index 00000000..7ce3302f --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java @@ -0,0 +1,6 @@ +package org.machinecoding.models.teleports; + +public interface Teleporter { + boolean canBeUsed(int currentPosition); + int teleport(); +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java new file mode 100644 index 00000000..3e03eb8f --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java @@ -0,0 +1,29 @@ +package org.machinecoding.models.teleports; + +public class TeleporterEntity implements Teleporter { + private final int startCell; + private final int endCell; + + public TeleporterEntity(int startCell, int endCell){ + this.startCell = startCell; + this.endCell = endCell; + } + + @Override + public boolean canBeUsed(int currentPosition) { + return (startCell == currentPosition); + } + + @Override + public int teleport() { + return endCell; + } + + public int getStartCell() { + return startCell; + } + + public int getEndCell() { + return endCell; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java new file mode 100644 index 00000000..a01d73de --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java @@ -0,0 +1,22 @@ +package org.machinecoding.strategy; + +import org.machinecoding.models.Dice; + +import java.util.List; + +public class DiceMovementStrategy implements MovementStrategy { + private final List dices; + + public DiceMovementStrategy(List dices) { + this.dices = dices; + } + + @Override + public int move(int pos) { + int steps = 0; + for (Dice dice : dices) { + steps += dice.roll(); + } + return pos + steps; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java new file mode 100644 index 00000000..64a6c1af --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java @@ -0,0 +1,34 @@ +package org.machinecoding.strategy; + +public class GameMovementStrategy implements MovementStrategy { + final DiceMovementStrategy diceMovementStrategy; + final TeleporterMovementStrategy teleporterMovementStrategy; + + private int diceValue = 0; + private int teleporterValue = 0; + + public GameMovementStrategy(DiceMovementStrategy diceMovementStrategy, + TeleporterMovementStrategy teleporterMovementStrategy) { + this.diceMovementStrategy = diceMovementStrategy; + this.teleporterMovementStrategy = teleporterMovementStrategy; + } + + @Override + public int move(int pos) { + int diceMovedPosition = diceMovementStrategy.move(pos); + this.diceValue = diceMovedPosition - pos; + + int teleporterMovedPosition = teleporterMovementStrategy.move(diceMovedPosition); + this.teleporterValue = teleporterMovedPosition - diceMovedPosition; + + return teleporterMovedPosition; + } + + public int getDiceValue() { + return diceValue; + } + public int getTeleporterValue() { + return teleporterValue; + } + +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java new file mode 100644 index 00000000..f7931c34 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java @@ -0,0 +1,6 @@ +package org.machinecoding.strategy; + +public interface MovementStrategy { + int move(int pos); + +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java new file mode 100644 index 00000000..58d537ea --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java @@ -0,0 +1,37 @@ +package org.machinecoding.strategy; + +import org.machinecoding.models.teleports.TeleporterEntity; + +import java.util.List; + +public class TeleporterMovementStrategy implements MovementStrategy { + private final List teleports; + + public TeleporterMovementStrategy(List teleports) { + this.teleports = teleports; + } + + @Override + public int move(int pos) { + int currentPosition = pos; + + while (true) { + boolean teleported = false; + + for (TeleporterEntity teleport : teleports) { + if (teleport.canBeUsed(currentPosition)) { + currentPosition = teleport.teleport(); + teleported = true; + break; + } + } + + if (!teleported) { + break; + } + } + + return currentPosition; + } + +} diff --git a/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java b/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java new file mode 100644 index 00000000..f9c0ad8c --- /dev/null +++ b/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java @@ -0,0 +1,202 @@ +package org.machinecoding.strategy; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; + +class GameMovementStrategyTest { + + private DiceMovementStrategy diceMovementStrategy; + private TeleporterMovementStrategy teleporterMovementStrategy; + private GameMovementStrategy gameMovementStrategy; + + @BeforeEach + void setUp() { + diceMovementStrategy = Mockito.mock(DiceMovementStrategy.class); + teleporterMovementStrategy = Mockito.mock(TeleporterMovementStrategy.class); + gameMovementStrategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + } + + // Test Scenario: Test the move method to ensure it correctly calculates the new position using both dice and teleporter strategies, and updates diceValue and teleporterValue accordingly. + @Test + void testMoveMethodCalculatesNewPositionAndUpdatesValues() { + int initialPosition = 0; + when(diceMovementStrategy.move(initialPosition)).thenReturn(5); + when(teleporterMovementStrategy.move(5)).thenReturn(10); + + int finalPosition = gameMovementStrategy.move(initialPosition); + + assertEquals(10, finalPosition); + assertEquals(5, gameMovementStrategy.getDiceValue()); + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test if the GameMovementStrategy correctly utilizes the DiceMovementStrategy to calculate the diceValue when move is called. + @Test + void testDiceValueCalculation() { + int initialPosition = 2; + when(diceMovementStrategy.move(initialPosition)).thenReturn(7); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test the behavior of GameMovementStrategy when teleporterMovementStrategy returns a position that is significantly different from the diceMovementStrategy's result, ensuring teleporterValue is calculated correctly. + @Test + void testTeleporterValueWithSignificantDifference() { + int initialPosition = 3; + when(diceMovementStrategy.move(initialPosition)).thenReturn(8); + when(teleporterMovementStrategy.move(8)).thenReturn(20); + + gameMovementStrategy.move(initialPosition); + + assertEquals(12, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the diceValue is correctly updated after the move method is called, reflecting the difference between the initial position and the position after the dice movement strategy is applied. + @Test + void testDiceValueUpdateAfterMove() { + int initialPosition = 4; + when(diceMovementStrategy.move(initialPosition)).thenReturn(9); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test teleporterValue calculation when teleporterMovementStrategy moves the position forward. + @Test + void testTeleporterValueCalculationForwardMove() { + int initialPosition = 5; + when(diceMovementStrategy.move(initialPosition)).thenReturn(10); + when(teleporterMovementStrategy.move(10)).thenReturn(15); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test the constructor to ensure it correctly initializes the GameMovementStrategy with given DiceMovementStrategy and TeleporterMovementStrategy instances. + @Test + void testConstructorInitialization() { + GameMovementStrategy strategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + assertEquals(diceMovementStrategy, strategy.diceMovementStrategy); + assertEquals(teleporterMovementStrategy, strategy.teleporterMovementStrategy); + } + + // Test Scenario: Verify that the GameMovementStrategy constructor correctly assigns the provided DiceMovementStrategy instance to the diceMovementStrategy field, ensuring that subsequent calls to move() use this instance for dice movement calculations. + @Test + void testDiceMovementStrategyAssignmentInConstructor() { + GameMovementStrategy strategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + assertEquals(diceMovementStrategy, strategy.diceMovementStrategy); + } + + // Test Scenario: Verify that the teleporterMovementStrategy correctly updates the teleporterValue after moving from the diceMovedPosition, ensuring the teleporterValue reflects the difference between the teleporterMovedPosition and diceMovedPosition. + @Test + void testTeleporterMovementStrategyUpdatesTeleporterValue() { + int initialPosition = 6; + when(diceMovementStrategy.move(initialPosition)).thenReturn(11); + when(teleporterMovementStrategy.move(11)).thenReturn(16); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test the move method with a starting position of 0, ensuring the dice and teleporter strategies are called correctly, and the final position is calculated accurately. + @Test + void testMoveMethodWithStartingPositionZero() { + int initialPosition = 0; + when(diceMovementStrategy.move(initialPosition)).thenReturn(3); + when(teleporterMovementStrategy.move(3)).thenReturn(8); + + int finalPosition = gameMovementStrategy.move(initialPosition); + + assertEquals(8, finalPosition); + } + + // Test Scenario: Test the move method to ensure it correctly updates diceValue when diceMovementStrategy returns a positive move. + @Test + void testDiceValueUpdateWithPositiveMove() { + int initialPosition = 7; + when(diceMovementStrategy.move(initialPosition)).thenReturn(12); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Verify that the diceValue is correctly updated when the move method is called, ensuring it reflects the difference between the new position after dice movement and the initial position. + @Test + void testDiceValueCorrectUpdateAfterMove() { + int initialPosition = 8; + when(diceMovementStrategy.move(initialPosition)).thenReturn(13); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test teleporter movement when dice movement results in a position that triggers a teleportation event. + @Test + void testTeleporterMovementOnDiceTrigger() { + int initialPosition = 9; + when(diceMovementStrategy.move(initialPosition)).thenReturn(14); + when(teleporterMovementStrategy.move(14)).thenReturn(19); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test teleporterValue calculation when teleporterMovementStrategy moves forward by 5 positions from a diceMovedPosition of 10. + @Test + void testTeleporterValueCalculationWithForwardMove() { + int initialPosition = 10; + when(diceMovementStrategy.move(initialPosition)).thenReturn(15); + when(teleporterMovementStrategy.move(15)).thenReturn(20); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the move method correctly updates the teleporterMovedPosition based on the teleporterMovementStrategy's move result, ensuring the teleporterValue reflects the difference between the teleporterMovedPosition and diceMovedPosition. + @Test + void testTeleporterMovedPositionUpdate() { + int initialPosition = 11; + when(diceMovementStrategy.move(initialPosition)).thenReturn(16); + when(teleporterMovementStrategy.move(16)).thenReturn(21); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the getDiceValue() method returns the correct dice movement value after a move operation is performed. + @Test + void testGetDiceValueMethod() { + int initialPosition = 12; + when(diceMovementStrategy.move(initialPosition)).thenReturn(17); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Verify that getTeleporterValue() returns the correct teleporter movement value after move() is called. + @Test + void testGetTeleporterValueMethod() { + int initialPosition = 13; + when(diceMovementStrategy.move(initialPosition)).thenReturn(18); + when(teleporterMovementStrategy.move(18)).thenReturn(23); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } +} \ No newline at end of file diff --git a/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar b/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..cc99851e3757cb6408942969f4813a7fdfd04432 GIT binary patch literal 11157 zcmbVS1z43!w+89%6iEr`?oMH|>5!7#ba$6@w;-V)AV{Y)64KpBHz-P%)ZHAc>FC1%$3 zwdJ*Y5I2+fK39V~bA<*^!p7d@uWA0e2j<^Btn>{{&8$I&Hb!RFf9g;0%l=k2Mj%Uv zKaipL(=bPnCCJvs-tkWW_kRiC;ApS!2r_Z|f%4t$LIV%{XS=NQok7-r=uGzS&S3U2 z{*F0!X)*mb!~X^oyXEwE0lL{cm}pM#6EKJxBm~4m@b}H${Y?CCPK(;;+Z!<&TIxGE zc*z6g+L*D^p64QP_$BR6laftU>BKHlW8mKN&IL%%150VH>CdYBZFU3fNgo&`UU-z2)=Qe+mvdc zbp}XZgTO>iI<>dM^@=*^%SYQQ)^nc`6cPSfo!5trdo08GlUIb=djpWVfQSYs^*v*5 zJ$@rjlez2gX+BfutDw_F4PP?DcH(G?jtX78C}!BY9+!j0D8B1%wA+(+!??o)?>EX6NnbCg%g~U2Pd=)ScrM$p8GB37j%MWSxKjJ8DuF&ar*iDne{sY zUSD0BDrOyaO0J2o5rom2kg{N_5bx1`QeYaYlb+##HQW5VzEjUfo+ss&?C zG3+PF{z_3qK>|y~Pi}@Fa-*^@S$~Uw&%#z?VBk~k{hewKYLC}z1oHvHbERnr0m|b? zSeV|iVYrou?Cy2>8&;hT(sXMFw5~w}@&v^jbU`ZgNntYcV^ofviRGL)fSf``3nNGM z7JEO}9N?q_yF5vHh|Q$Edr712;8xOeMg*KRU9Vx3fQ)*Y5a+@e7VSr++^o;79EDrV z{d(W}er4n-;7c4TC?yX8ZN{8hz;sX?1eDR%i&w!QX~|(9cx8q;)r3fQ^`9}7<`eFE zwg90K@KrI|-2Gzs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)e zoF2Eev0`+!vJ6zxv1uj6_Sz{i{q{7kE;vV|uiSDPGo6aJLS1r)7J!7J@Oh8~((%P+ z$Ndve?XOF5)0tKy0;UuRX~q;PMvopB(~^BQJ8p6t*r^}@K7KRKWt+-d%|2>rVx?{{ zTQ2apowviqH=%gXy!O3Io-L!aJO5K9;t1~UAbsJscBBpomR6GRvyVKL^mrprsCd$P zBWWU~Hp19GzdW-!Kg3BTnk7V(AEV}JLA#c)kb*D5uy6HP^vU`-SH zhXD=nf}(z1l{mT)TIwMUon3rl_c**EoX$2rzY8A!2C5}<^_iZ!6oHdN2+CL{(-$rN zD98RPRx3pM1 z$u0kH$`jC}8|Q?;e18mn1pa^gx3#yi1=%~AfgAwzwB51*S;jrtvVNfKKvy5YX+XZa z53nJ_)WgI85w?z(^H~HGN5%@um-vu!=2ji#4qMma9R=A!d_|@W)>V-Au%UimRRf+L zxS>OQ5xM#PM^e5I`+b$oP3N1I?MDs%`_Hf+YHofc{Hqd~zlQ%sxDfn$6M6a5h?|m` z@9k!)1K`(x$7=pG{-%WHd%GEb1%Cba_$;y1~l@9hSL1ANAQ3v(MX`qR8_ zN^EWcoqq}Vk7x5E(A_eao06Mbpb{|9Kb!KO0-W1r-5pH!pRs@K$LzlcgID>lf}G#O z-GtJ3aLT|6wyCpjRfzS3c1%v-~3w|irxr=zWcI6f^6P%X% zGvbfQgS)tQGl#dh9^fmxDEPlZ`bU-gK1gzx#9eRpmP9S#A4%Lw$*(Q>yM*q# z2DgO9AN-Nfe+PfpOuvQCBmN`&?~V2!SMV#l>y`vBSi}Awb>QDt*pD=RWn0|Rs3ZS> b(YUoV6aX;bYCZ@E0`P|pT!gFg*KPMd;T;ic literal 0 HcmV?d00001 diff --git a/snakeAndLadder/target/maven-archiver/pom.properties b/snakeAndLadder/target/maven-archiver/pom.properties new file mode 100644 index 00000000..5d69c9bf --- /dev/null +++ b/snakeAndLadder/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=machineCoding +groupId=org.machinecoding +version=1.0-SNAPSHOT diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 00000000..bb20f7d4 --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,13 @@ +org/machinecoding/strategy/TeleporterMovementStrategy.class +org/machinecoding/models/teleports/Ladder.class +org/machinecoding/models/Dice.class +org/machinecoding/models/Board.class +org/machinecoding/strategy/MovementStrategy.class +org/machinecoding/models/BoardEntity.class +org/machinecoding/models/teleports/Teleporter.class +org/machinecoding/models/teleports/TeleporterEntity.class +org/machinecoding/strategy/DiceMovementStrategy.class +org/machinecoding/models/Player.class +org/machinecoding/strategy/GameMovementStrategy.class +org/machinecoding/models/teleports/Snake.class +org/machinecoding/Main.class diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 00000000..d341e44e --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/Main.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Board.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/BoardEntity.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Dice.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Player.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Ladder.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Snake.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Teleporter.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/MovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 00000000..e69de29b diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 00000000..9de02e91 --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java From dfc88f7a915e85f3cb031f176911b38706b381d6 Mon Sep 17 00:00:00 2001 From: Sanchit Sinha <68417985+sanchit-sinha@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:30:33 +0530 Subject: [PATCH 2/7] solved snake and ladder implementation (#1) --- snakeAndLadder/pom.xml | 30 +++ .../src/main/java/org/machinecoding/Main.java | 49 +++++ .../java/org/machinecoding/models/Board.java | 7 + .../org/machinecoding/models/BoardEntity.java | 54 +++++ .../java/org/machinecoding/models/Dice.java | 7 + .../java/org/machinecoding/models/Player.java | 29 +++ .../models/teleports/Ladder.java | 7 + .../machinecoding/models/teleports/Snake.java | 7 + .../models/teleports/Teleporter.java | 6 + .../models/teleports/TeleporterEntity.java | 29 +++ .../strategy/DiceMovementStrategy.java | 22 ++ .../strategy/GameMovementStrategy.java | 34 +++ .../strategy/MovementStrategy.java | 6 + .../strategy/TeleporterMovementStrategy.java | 37 ++++ .../strategy/GameMovementStrategyTest.java | 202 ++++++++++++++++++ .../target/machineCoding-1.0-SNAPSHOT.jar | Bin 0 -> 11157 bytes .../target/maven-archiver/pom.properties | 3 + .../compile/default-compile/createdFiles.lst | 13 ++ .../compile/default-compile/inputFiles.lst | 13 ++ .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 + 21 files changed, 556 insertions(+) create mode 100644 snakeAndLadder/pom.xml create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/Main.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Board.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/Player.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java create mode 100644 snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java create mode 100644 snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java create mode 100644 snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar create mode 100644 snakeAndLadder/target/maven-archiver/pom.properties create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/snakeAndLadder/pom.xml b/snakeAndLadder/pom.xml new file mode 100644 index 00000000..424f86a0 --- /dev/null +++ b/snakeAndLadder/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.machinecoding + snakeAndLadder + 1.0-SNAPSHOT + + + 23 + 23 + UTF-8 + + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + org.mockito + mockito-core + 4.0.0 + test + + + diff --git a/snakeAndLadder/src/main/java/org/machinecoding/Main.java b/snakeAndLadder/src/main/java/org/machinecoding/Main.java new file mode 100644 index 00000000..430d4645 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/Main.java @@ -0,0 +1,49 @@ +package org.machinecoding; + +import org.machinecoding.models.Board; +import org.machinecoding.models.BoardEntity; +import org.machinecoding.models.Dice; +import org.machinecoding.models.Player; +import org.machinecoding.models.teleports.Ladder; +import org.machinecoding.models.teleports.Snake; +import org.machinecoding.models.teleports.TeleporterEntity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int targetCell = 100; + + int numSnakes = scan.nextInt(); + List teleporterList = new ArrayList<>(); + for (int i = 0; i < numSnakes; i++) + teleporterList.add(new Snake(scan.nextInt(), scan.nextInt())); + + int numLadder = scan.nextInt(); + for (int i = 0; i < numLadder; i++) + teleporterList.add(new Ladder(scan.nextInt(), scan.nextInt())); + + int numPlayers = scan.nextInt(); + List playerList = new ArrayList<>(); + for (int i = 0; i < numPlayers; i++) + playerList.add(new Player(scan.next(), 0, targetCell)); + + // debug +// for (TeleporterEntity teleporter : teleporterList) +// System.out.println("start: " + teleporter.getStartCell() + +// ", end: " + teleporter.getEndCell()); +// +// for (Player player : playerList) +// System.out.println(player.getName() + " is at " + player.getPosition()); + + List diceList = new ArrayList<>(); + diceList.add(new Dice()); + + BoardEntity boardEntity = new BoardEntity(new Board(targetCell), + teleporterList, playerList, diceList); + boardEntity.start(); + } +} \ No newline at end of file diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java new file mode 100644 index 00000000..64f66bf8 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Board.java @@ -0,0 +1,7 @@ +package org.machinecoding.models; + +public class Board { + private int cells; + + public Board(int cells) { this.cells = cells; } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java b/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java new file mode 100644 index 00000000..9efb7a13 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java @@ -0,0 +1,54 @@ +package org.machinecoding.models; + +import org.machinecoding.models.teleports.TeleporterEntity; +import org.machinecoding.strategy.DiceMovementStrategy; +import org.machinecoding.strategy.GameMovementStrategy; +import org.machinecoding.strategy.TeleporterMovementStrategy; + +import java.util.List; + +public class BoardEntity { + private final Board board; + private final List teleports; + private final List players; + private final List dices; + + private GameMovementStrategy movementStrategy; + + public BoardEntity(Board board, List teleports, List players, List dices) { + this.board = board; + this.teleports = teleports; + this.players = players; + this.dices = dices; + + this.movementStrategy = new GameMovementStrategy(new DiceMovementStrategy(dices), new TeleporterMovementStrategy(teleports)); + } + + public void start() { + while(shouldPerformRound()){ + performOneRound(); + } + } + + private boolean shouldPerformRound() { + return players.stream().filter(p -> !p.isWinner()).count() > 1; + } + + public void performOneRound(){ + for (Player player : players) { + if(!shouldPerformRound()) return; + + int currentPosition = player.getPosition(); + int newPosition = movementStrategy.move(currentPosition); + player.move(newPosition); + + System.out.println(player.getName() + " rolled a " + movementStrategy.getDiceValue() + " and moved from " + + currentPosition + " to " + player.getPosition()); + + if (player.isWinner()) { + System.out.println(player.getName() + " wins the game"); + } + } + } +} + diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java new file mode 100644 index 00000000..c8aba8dd --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Dice.java @@ -0,0 +1,7 @@ +package org.machinecoding.models; + +public class Dice { + public int roll() { + return (int) (Math.random() * 6) + 1; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java b/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java new file mode 100644 index 00000000..b9f54f75 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/Player.java @@ -0,0 +1,29 @@ +package org.machinecoding.models; + +public class Player { + private final String name; + private int position; + private final int targetPosition; + + public Player(String name, int startPosition, int targetPosition){ + this.name = name; + this.position = startPosition; + this.targetPosition = targetPosition; + } + + public void move(int newPosition){ + this.position = (newPosition > targetPosition) ? position : newPosition; + } + + public boolean isWinner(){ + return (position == targetPosition); + } + + public int getPosition(){ + return position; + } + + public String getName(){ + return name; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java new file mode 100644 index 00000000..896afcee --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Ladder.java @@ -0,0 +1,7 @@ +package org.machinecoding.models.teleports; + +public class Ladder extends TeleporterEntity { + public Ladder(int startCell, int endCell) { + super(startCell, endCell); + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java new file mode 100644 index 00000000..63f45446 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Snake.java @@ -0,0 +1,7 @@ +package org.machinecoding.models.teleports; + +public class Snake extends TeleporterEntity { + public Snake(int startCell, int endCell) { + super(startCell, endCell); + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java new file mode 100644 index 00000000..7ce3302f --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/Teleporter.java @@ -0,0 +1,6 @@ +package org.machinecoding.models.teleports; + +public interface Teleporter { + boolean canBeUsed(int currentPosition); + int teleport(); +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java new file mode 100644 index 00000000..3e03eb8f --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java @@ -0,0 +1,29 @@ +package org.machinecoding.models.teleports; + +public class TeleporterEntity implements Teleporter { + private final int startCell; + private final int endCell; + + public TeleporterEntity(int startCell, int endCell){ + this.startCell = startCell; + this.endCell = endCell; + } + + @Override + public boolean canBeUsed(int currentPosition) { + return (startCell == currentPosition); + } + + @Override + public int teleport() { + return endCell; + } + + public int getStartCell() { + return startCell; + } + + public int getEndCell() { + return endCell; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java new file mode 100644 index 00000000..a01d73de --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java @@ -0,0 +1,22 @@ +package org.machinecoding.strategy; + +import org.machinecoding.models.Dice; + +import java.util.List; + +public class DiceMovementStrategy implements MovementStrategy { + private final List dices; + + public DiceMovementStrategy(List dices) { + this.dices = dices; + } + + @Override + public int move(int pos) { + int steps = 0; + for (Dice dice : dices) { + steps += dice.roll(); + } + return pos + steps; + } +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java new file mode 100644 index 00000000..64a6c1af --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java @@ -0,0 +1,34 @@ +package org.machinecoding.strategy; + +public class GameMovementStrategy implements MovementStrategy { + final DiceMovementStrategy diceMovementStrategy; + final TeleporterMovementStrategy teleporterMovementStrategy; + + private int diceValue = 0; + private int teleporterValue = 0; + + public GameMovementStrategy(DiceMovementStrategy diceMovementStrategy, + TeleporterMovementStrategy teleporterMovementStrategy) { + this.diceMovementStrategy = diceMovementStrategy; + this.teleporterMovementStrategy = teleporterMovementStrategy; + } + + @Override + public int move(int pos) { + int diceMovedPosition = diceMovementStrategy.move(pos); + this.diceValue = diceMovedPosition - pos; + + int teleporterMovedPosition = teleporterMovementStrategy.move(diceMovedPosition); + this.teleporterValue = teleporterMovedPosition - diceMovedPosition; + + return teleporterMovedPosition; + } + + public int getDiceValue() { + return diceValue; + } + public int getTeleporterValue() { + return teleporterValue; + } + +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java new file mode 100644 index 00000000..f7931c34 --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/MovementStrategy.java @@ -0,0 +1,6 @@ +package org.machinecoding.strategy; + +public interface MovementStrategy { + int move(int pos); + +} diff --git a/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java b/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java new file mode 100644 index 00000000..58d537ea --- /dev/null +++ b/snakeAndLadder/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java @@ -0,0 +1,37 @@ +package org.machinecoding.strategy; + +import org.machinecoding.models.teleports.TeleporterEntity; + +import java.util.List; + +public class TeleporterMovementStrategy implements MovementStrategy { + private final List teleports; + + public TeleporterMovementStrategy(List teleports) { + this.teleports = teleports; + } + + @Override + public int move(int pos) { + int currentPosition = pos; + + while (true) { + boolean teleported = false; + + for (TeleporterEntity teleport : teleports) { + if (teleport.canBeUsed(currentPosition)) { + currentPosition = teleport.teleport(); + teleported = true; + break; + } + } + + if (!teleported) { + break; + } + } + + return currentPosition; + } + +} diff --git a/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java b/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java new file mode 100644 index 00000000..f9c0ad8c --- /dev/null +++ b/snakeAndLadder/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java @@ -0,0 +1,202 @@ +package org.machinecoding.strategy; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; + +class GameMovementStrategyTest { + + private DiceMovementStrategy diceMovementStrategy; + private TeleporterMovementStrategy teleporterMovementStrategy; + private GameMovementStrategy gameMovementStrategy; + + @BeforeEach + void setUp() { + diceMovementStrategy = Mockito.mock(DiceMovementStrategy.class); + teleporterMovementStrategy = Mockito.mock(TeleporterMovementStrategy.class); + gameMovementStrategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + } + + // Test Scenario: Test the move method to ensure it correctly calculates the new position using both dice and teleporter strategies, and updates diceValue and teleporterValue accordingly. + @Test + void testMoveMethodCalculatesNewPositionAndUpdatesValues() { + int initialPosition = 0; + when(diceMovementStrategy.move(initialPosition)).thenReturn(5); + when(teleporterMovementStrategy.move(5)).thenReturn(10); + + int finalPosition = gameMovementStrategy.move(initialPosition); + + assertEquals(10, finalPosition); + assertEquals(5, gameMovementStrategy.getDiceValue()); + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test if the GameMovementStrategy correctly utilizes the DiceMovementStrategy to calculate the diceValue when move is called. + @Test + void testDiceValueCalculation() { + int initialPosition = 2; + when(diceMovementStrategy.move(initialPosition)).thenReturn(7); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test the behavior of GameMovementStrategy when teleporterMovementStrategy returns a position that is significantly different from the diceMovementStrategy's result, ensuring teleporterValue is calculated correctly. + @Test + void testTeleporterValueWithSignificantDifference() { + int initialPosition = 3; + when(diceMovementStrategy.move(initialPosition)).thenReturn(8); + when(teleporterMovementStrategy.move(8)).thenReturn(20); + + gameMovementStrategy.move(initialPosition); + + assertEquals(12, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the diceValue is correctly updated after the move method is called, reflecting the difference between the initial position and the position after the dice movement strategy is applied. + @Test + void testDiceValueUpdateAfterMove() { + int initialPosition = 4; + when(diceMovementStrategy.move(initialPosition)).thenReturn(9); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test teleporterValue calculation when teleporterMovementStrategy moves the position forward. + @Test + void testTeleporterValueCalculationForwardMove() { + int initialPosition = 5; + when(diceMovementStrategy.move(initialPosition)).thenReturn(10); + when(teleporterMovementStrategy.move(10)).thenReturn(15); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test the constructor to ensure it correctly initializes the GameMovementStrategy with given DiceMovementStrategy and TeleporterMovementStrategy instances. + @Test + void testConstructorInitialization() { + GameMovementStrategy strategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + assertEquals(diceMovementStrategy, strategy.diceMovementStrategy); + assertEquals(teleporterMovementStrategy, strategy.teleporterMovementStrategy); + } + + // Test Scenario: Verify that the GameMovementStrategy constructor correctly assigns the provided DiceMovementStrategy instance to the diceMovementStrategy field, ensuring that subsequent calls to move() use this instance for dice movement calculations. + @Test + void testDiceMovementStrategyAssignmentInConstructor() { + GameMovementStrategy strategy = new GameMovementStrategy(diceMovementStrategy, teleporterMovementStrategy); + assertEquals(diceMovementStrategy, strategy.diceMovementStrategy); + } + + // Test Scenario: Verify that the teleporterMovementStrategy correctly updates the teleporterValue after moving from the diceMovedPosition, ensuring the teleporterValue reflects the difference between the teleporterMovedPosition and diceMovedPosition. + @Test + void testTeleporterMovementStrategyUpdatesTeleporterValue() { + int initialPosition = 6; + when(diceMovementStrategy.move(initialPosition)).thenReturn(11); + when(teleporterMovementStrategy.move(11)).thenReturn(16); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test the move method with a starting position of 0, ensuring the dice and teleporter strategies are called correctly, and the final position is calculated accurately. + @Test + void testMoveMethodWithStartingPositionZero() { + int initialPosition = 0; + when(diceMovementStrategy.move(initialPosition)).thenReturn(3); + when(teleporterMovementStrategy.move(3)).thenReturn(8); + + int finalPosition = gameMovementStrategy.move(initialPosition); + + assertEquals(8, finalPosition); + } + + // Test Scenario: Test the move method to ensure it correctly updates diceValue when diceMovementStrategy returns a positive move. + @Test + void testDiceValueUpdateWithPositiveMove() { + int initialPosition = 7; + when(diceMovementStrategy.move(initialPosition)).thenReturn(12); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Verify that the diceValue is correctly updated when the move method is called, ensuring it reflects the difference between the new position after dice movement and the initial position. + @Test + void testDiceValueCorrectUpdateAfterMove() { + int initialPosition = 8; + when(diceMovementStrategy.move(initialPosition)).thenReturn(13); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Test teleporter movement when dice movement results in a position that triggers a teleportation event. + @Test + void testTeleporterMovementOnDiceTrigger() { + int initialPosition = 9; + when(diceMovementStrategy.move(initialPosition)).thenReturn(14); + when(teleporterMovementStrategy.move(14)).thenReturn(19); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Test teleporterValue calculation when teleporterMovementStrategy moves forward by 5 positions from a diceMovedPosition of 10. + @Test + void testTeleporterValueCalculationWithForwardMove() { + int initialPosition = 10; + when(diceMovementStrategy.move(initialPosition)).thenReturn(15); + when(teleporterMovementStrategy.move(15)).thenReturn(20); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the move method correctly updates the teleporterMovedPosition based on the teleporterMovementStrategy's move result, ensuring the teleporterValue reflects the difference between the teleporterMovedPosition and diceMovedPosition. + @Test + void testTeleporterMovedPositionUpdate() { + int initialPosition = 11; + when(diceMovementStrategy.move(initialPosition)).thenReturn(16); + when(teleporterMovementStrategy.move(16)).thenReturn(21); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } + + // Test Scenario: Verify that the getDiceValue() method returns the correct dice movement value after a move operation is performed. + @Test + void testGetDiceValueMethod() { + int initialPosition = 12; + when(diceMovementStrategy.move(initialPosition)).thenReturn(17); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getDiceValue()); + } + + // Test Scenario: Verify that getTeleporterValue() returns the correct teleporter movement value after move() is called. + @Test + void testGetTeleporterValueMethod() { + int initialPosition = 13; + when(diceMovementStrategy.move(initialPosition)).thenReturn(18); + when(teleporterMovementStrategy.move(18)).thenReturn(23); + + gameMovementStrategy.move(initialPosition); + + assertEquals(5, gameMovementStrategy.getTeleporterValue()); + } +} \ No newline at end of file diff --git a/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar b/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..cc99851e3757cb6408942969f4813a7fdfd04432 GIT binary patch literal 11157 zcmbVS1z43!w+89%6iEr`?oMH|>5!7#ba$6@w;-V)AV{Y)64KpBHz-P%)ZHAc>FC1%$3 zwdJ*Y5I2+fK39V~bA<*^!p7d@uWA0e2j<^Btn>{{&8$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X$2rzY8A!2C5}<^_iZ!6oHdN2+CL{(-$rN zD98RPRx3pM1 z$u0kH$`jC}8|Q?;e18mn1pa^gx3#yi1=%~AfgAwzwB51*S;jrtvVNfKKvy5YX+XZa z53nJ_)WgI85w?z(^H~HGN5%@um-vu!=2ji#4qMma9R=A!d_|@W)>V-Au%UimRRf+L zxS>OQ5xM#PM^e5I`+b$oP3N1I?MDs%`_Hf+YHofc{Hqd~zlQ%sxDfn$6M6a5h?|m` z@9k!)1K`(x$7=pG{-%WHd%GEb1%Cba_$;y1~l@9hSL1ANAQ3v(MX`qR8_ zN^EWcoqq}Vk7x5E(A_eao06Mbpb{|9Kb!KO0-W1r-5pH!pRs@K$LzlcgID>lf}G#O z-GtJ3aLT|6wyCpjRfzS3c1%v-~3w|irxr=zWcI6f^6P%X% zGvbfQgS)tQGl#dh9^fmxDEPlZ`bU-gK1gzx#9eRpmP9S#A4%Lw$*(Q>yM*q# z2DgO9AN-Nfe+PfpOuvQCBmN`&?~V2!SMV#l>y`vBSi}Awb>QDt*pD=RWn0|Rs3ZS> b(YUoV6aX;bYCZ@E0`P|pT!gFg*KPMd;T;ic literal 0 HcmV?d00001 diff --git a/snakeAndLadder/target/maven-archiver/pom.properties b/snakeAndLadder/target/maven-archiver/pom.properties new file mode 100644 index 00000000..5d69c9bf --- /dev/null +++ b/snakeAndLadder/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=machineCoding +groupId=org.machinecoding +version=1.0-SNAPSHOT diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 00000000..bb20f7d4 --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,13 @@ +org/machinecoding/strategy/TeleporterMovementStrategy.class +org/machinecoding/models/teleports/Ladder.class +org/machinecoding/models/Dice.class +org/machinecoding/models/Board.class +org/machinecoding/strategy/MovementStrategy.class +org/machinecoding/models/BoardEntity.class +org/machinecoding/models/teleports/Teleporter.class +org/machinecoding/models/teleports/TeleporterEntity.class +org/machinecoding/strategy/DiceMovementStrategy.class +org/machinecoding/models/Player.class +org/machinecoding/strategy/GameMovementStrategy.class +org/machinecoding/models/teleports/Snake.class +org/machinecoding/Main.class diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 00000000..d341e44e --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/Main.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Board.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/BoardEntity.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Dice.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Player.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Ladder.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Snake.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Teleporter.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/MovementStrategy.java +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 00000000..e69de29b diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 00000000..9de02e91 --- /dev/null +++ b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java From 8e432809471ba6a65c030d41e5b04058929334a4 Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Sun, 2 Feb 2025 22:34:03 +0530 Subject: [PATCH 3/7] add implementation --- .gitignore | 163 ++++++++++++++++++ pom.xml | 15 ++ .../src/main/java/org/machinecoding/Main.java | 8 - .../target/machineCoding-1.0-SNAPSHOT.jar | Bin 11157 -> 0 bytes .../target/maven-archiver/pom.properties | 3 - .../compile/default-compile/createdFiles.lst | 13 -- .../compile/default-compile/inputFiles.lst | 13 -- .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 - 9 files changed, 178 insertions(+), 38 deletions(-) create mode 100644 pom.xml delete mode 100644 snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar delete mode 100644 snakeAndLadder/target/maven-archiver/pom.properties delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/.gitignore b/.gitignore index 36b741e6..116000c9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,167 @@ tests/out .idea .DS_Store .* +# Created by https://www.toptal.com/developers/gitignore/api/intellij,maven,java +# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,maven,java + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/intellij,maven,java + !.gitignore diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..860e1b32 --- /dev/null +++ b/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.machinecoding + machineCoding-parent + 1.0-SNAPSHOT + pom + + + snakeAndLadder + + diff --git a/snakeAndLadder/src/main/java/org/machinecoding/Main.java b/snakeAndLadder/src/main/java/org/machinecoding/Main.java index 430d4645..e6e1cc19 100644 --- a/snakeAndLadder/src/main/java/org/machinecoding/Main.java +++ b/snakeAndLadder/src/main/java/org/machinecoding/Main.java @@ -31,14 +31,6 @@ public static void main(String[] args) { for (int i = 0; i < numPlayers; i++) playerList.add(new Player(scan.next(), 0, targetCell)); - // debug -// for (TeleporterEntity teleporter : teleporterList) -// System.out.println("start: " + teleporter.getStartCell() + -// ", end: " + teleporter.getEndCell()); -// -// for (Player player : playerList) -// System.out.println(player.getName() + " is at " + player.getPosition()); - List diceList = new ArrayList<>(); diceList.add(new Dice()); diff --git a/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar b/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar deleted file mode 100644 index cc99851e3757cb6408942969f4813a7fdfd04432..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11157 zcmbVS1z43!w+89%6iEr`?oMH|>5!7#ba$6@w;-V)AV{Y)64KpBHz-P%)ZHAc>FC1%$3 zwdJ*Y5I2+fK39V~bA<*^!p7d@uWA0e2j<^Btn>{{&8$I&Hb!RFf9g;0%l=k2Mj%Uv zKaipL(=bPnCCJvs-tkWW_kRiC;ApS!2r_Z|f%4t$LIV%{XS=NQok7-r=uGzS&S3U2 z{*F0!X)*mb!~X^oyXEwE0lL{cm}pM#6EKJxBm~4m@b}H${Y?CCPK(;;+Z!<&TIxGE zc*z6g+L*D^p64QP_$BR6laftU>BKHlW8mKN&IL%%150VH>CdYBZFU3fNgo&`UU-z2)=Qe+mvdc zbp}XZgTO>iI<>dM^@=*^%SYQQ)^nc`6cPSfo!5trdo08GlUIb=djpWVfQSYs^*v*5 zJ$@rjlez2gX+BfutDw_F4PP?DcH(G?jtX78C}!BY9+!j0D8B1%wA+(+!??o)?>EX6NnbCg%g~U2Pd=)ScrM$p8GB37j%MWSxKjJ8DuF&ar*iDne{sY zUSD0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6P%X% zGvbfQgS)tQGl#dh9^fmxDEPlZ`bU-gK1gzx#9eRpmP9S#A4%Lw$*(Q>yM*q# z2DgO9AN-Nfe+PfpOuvQCBmN`&?~V2!SMV#l>y`vBSi}Awb>QDt*pD=RWn0|Rs3ZS> b(YUoV6aX;bYCZ@E0`P|pT!gFg*KPMd;T;ic diff --git a/snakeAndLadder/target/maven-archiver/pom.properties b/snakeAndLadder/target/maven-archiver/pom.properties deleted file mode 100644 index 5d69c9bf..00000000 --- a/snakeAndLadder/target/maven-archiver/pom.properties +++ /dev/null @@ -1,3 +0,0 @@ -artifactId=machineCoding -groupId=org.machinecoding -version=1.0-SNAPSHOT diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index bb20f7d4..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -org/machinecoding/strategy/TeleporterMovementStrategy.class -org/machinecoding/models/teleports/Ladder.class -org/machinecoding/models/Dice.class -org/machinecoding/models/Board.class -org/machinecoding/strategy/MovementStrategy.class -org/machinecoding/models/BoardEntity.class -org/machinecoding/models/teleports/Teleporter.class -org/machinecoding/models/teleports/TeleporterEntity.class -org/machinecoding/strategy/DiceMovementStrategy.class -org/machinecoding/models/Player.class -org/machinecoding/strategy/GameMovementStrategy.class -org/machinecoding/models/teleports/Snake.class -org/machinecoding/Main.class diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index d341e44e..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/Main.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Board.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/BoardEntity.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Dice.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Player.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Ladder.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Snake.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Teleporter.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/MovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst deleted file mode 100644 index e69de29b..00000000 diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index 9de02e91..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java From 975818d97b4767a4e65c6cebf07d39dd65f9c66f Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Sun, 2 Feb 2025 22:37:36 +0530 Subject: [PATCH 4/7] remove logs --- snakeAndLadder/src/main/java/org/machinecoding/Main.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/snakeAndLadder/src/main/java/org/machinecoding/Main.java b/snakeAndLadder/src/main/java/org/machinecoding/Main.java index 430d4645..e6e1cc19 100644 --- a/snakeAndLadder/src/main/java/org/machinecoding/Main.java +++ b/snakeAndLadder/src/main/java/org/machinecoding/Main.java @@ -31,14 +31,6 @@ public static void main(String[] args) { for (int i = 0; i < numPlayers; i++) playerList.add(new Player(scan.next(), 0, targetCell)); - // debug -// for (TeleporterEntity teleporter : teleporterList) -// System.out.println("start: " + teleporter.getStartCell() + -// ", end: " + teleporter.getEndCell()); -// -// for (Player player : playerList) -// System.out.println(player.getName() + " is at " + player.getPosition()); - List diceList = new ArrayList<>(); diceList.add(new Dice()); From 528ab750f87cd910ccbda2b984d68bf80febf10b Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Sun, 2 Feb 2025 22:39:01 +0530 Subject: [PATCH 5/7] remove target --- .gitignore | 1 + .../target/machineCoding-1.0-SNAPSHOT.jar | Bin 11157 -> 0 bytes .../target/maven-archiver/pom.properties | 3 --- .../compile/default-compile/createdFiles.lst | 13 ------------- .../compile/default-compile/inputFiles.lst | 13 ------------- .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 - 7 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar delete mode 100644 snakeAndLadder/target/maven-archiver/pom.properties delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/.gitignore b/.gitignore index 116000c9..97d3341a 100644 --- a/.gitignore +++ b/.gitignore @@ -168,6 +168,7 @@ buildNumber.properties # JDT-specific (Eclipse Java Development Tools) .classpath +*/target/* # End of https://www.toptal.com/developers/gitignore/api/intellij,maven,java !.gitignore diff --git a/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar b/snakeAndLadder/target/machineCoding-1.0-SNAPSHOT.jar deleted file mode 100644 index cc99851e3757cb6408942969f4813a7fdfd04432..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11157 zcmbVS1z43!w+89%6iEr`?oMH|>5!7#ba$6@w;-V)AV{Y)64KpBHz-P%)ZHAc>FC1%$3 zwdJ*Y5I2+fK39V~bA<*^!p7d@uWA0e2j<^Btn>{{&8$I&Hb!RFf9g;0%l=k2Mj%Uv zKaipL(=bPnCCJvs-tkWW_kRiC;ApS!2r_Z|f%4t$LIV%{XS=NQok7-r=uGzS&S3U2 z{*F0!X)*mb!~X^oyXEwE0lL{cm}pM#6EKJxBm~4m@b}H${Y?CCPK(;;+Z!<&TIxGE zc*z6g+L*D^p64QP_$BR6laftU>BKHlW8mKN&IL%%150VH>CdYBZFU3fNgo&`UU-z2)=Qe+mvdc zbp}XZgTO>iI<>dM^@=*^%SYQQ)^nc`6cPSfo!5trdo08GlUIb=djpWVfQSYs^*v*5 zJ$@rjlez2gX+BfutDw_F4PP?DcH(G?jtX78C}!BY9+!j0D8B1%wA+(+!??o)?>EX6NnbCg%g~U2Pd=)ScrM$p8GB37j%MWSxKjJ8DuF&ar*iDne{sY zUSD0BDrOyaO0J2o5rom2kg{N_5bx1`QeYaYlb+##HQW5VzEjUfo+ss&?C zG3+PF{z_3qK>|y~Pi}@Fa-*^@S$~Uw&%#z?VBk~k{hewKYLC}z1oHvHbERnr0m|b? zSeV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pD=RWn0|Rs3ZS> b(YUoV6aX;bYCZ@E0`P|pT!gFg*KPMd;T;ic diff --git a/snakeAndLadder/target/maven-archiver/pom.properties b/snakeAndLadder/target/maven-archiver/pom.properties deleted file mode 100644 index 5d69c9bf..00000000 --- a/snakeAndLadder/target/maven-archiver/pom.properties +++ /dev/null @@ -1,3 +0,0 @@ -artifactId=machineCoding -groupId=org.machinecoding -version=1.0-SNAPSHOT diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index bb20f7d4..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -org/machinecoding/strategy/TeleporterMovementStrategy.class -org/machinecoding/models/teleports/Ladder.class -org/machinecoding/models/Dice.class -org/machinecoding/models/Board.class -org/machinecoding/strategy/MovementStrategy.class -org/machinecoding/models/BoardEntity.class -org/machinecoding/models/teleports/Teleporter.class -org/machinecoding/models/teleports/TeleporterEntity.class -org/machinecoding/strategy/DiceMovementStrategy.class -org/machinecoding/models/Player.class -org/machinecoding/strategy/GameMovementStrategy.class -org/machinecoding/models/teleports/Snake.class -org/machinecoding/Main.class diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index d341e44e..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/Main.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Board.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/BoardEntity.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Dice.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/Player.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Ladder.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Snake.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/Teleporter.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/models/teleports/TeleporterEntity.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/DiceMovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/GameMovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/MovementStrategy.java -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/main/java/org/machinecoding/strategy/TeleporterMovementStrategy.java diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst deleted file mode 100644 index e69de29b..00000000 diff --git a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index 9de02e91..00000000 --- a/snakeAndLadder/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -/Users/sanchitsinha/Desktop/machinecode/machineCoding/src/test/java/org/machinecoding/strategy/GameMovementStrategyTest.java From 73bd55c74de5f541762f6915d93f7400da21d7d7 Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Sun, 2 Feb 2025 22:54:29 +0530 Subject: [PATCH 6/7] reformat name --- snakeAndLadder/src/main/java/org/machinecoding/Main.java | 6 +++--- .../BoardEntity.java => services/GameController.java} | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) rename snakeAndLadder/src/main/java/org/machinecoding/{models/BoardEntity.java => services/GameController.java} (84%) diff --git a/snakeAndLadder/src/main/java/org/machinecoding/Main.java b/snakeAndLadder/src/main/java/org/machinecoding/Main.java index e6e1cc19..cf68cb56 100644 --- a/snakeAndLadder/src/main/java/org/machinecoding/Main.java +++ b/snakeAndLadder/src/main/java/org/machinecoding/Main.java @@ -1,7 +1,7 @@ package org.machinecoding; import org.machinecoding.models.Board; -import org.machinecoding.models.BoardEntity; +import org.machinecoding.services.GameController; import org.machinecoding.models.Dice; import org.machinecoding.models.Player; import org.machinecoding.models.teleports.Ladder; @@ -34,8 +34,8 @@ public static void main(String[] args) { List diceList = new ArrayList<>(); diceList.add(new Dice()); - BoardEntity boardEntity = new BoardEntity(new Board(targetCell), + GameController gameController = new GameController(new Board(targetCell), teleporterList, playerList, diceList); - boardEntity.start(); + gameController.start(); } } \ No newline at end of file diff --git a/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java b/snakeAndLadder/src/main/java/org/machinecoding/services/GameController.java similarity index 84% rename from snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java rename to snakeAndLadder/src/main/java/org/machinecoding/services/GameController.java index 9efb7a13..04bf1e22 100644 --- a/snakeAndLadder/src/main/java/org/machinecoding/models/BoardEntity.java +++ b/snakeAndLadder/src/main/java/org/machinecoding/services/GameController.java @@ -1,5 +1,8 @@ -package org.machinecoding.models; +package org.machinecoding.services; +import org.machinecoding.models.Board; +import org.machinecoding.models.Dice; +import org.machinecoding.models.Player; import org.machinecoding.models.teleports.TeleporterEntity; import org.machinecoding.strategy.DiceMovementStrategy; import org.machinecoding.strategy.GameMovementStrategy; @@ -7,7 +10,7 @@ import java.util.List; -public class BoardEntity { +public class GameController { private final Board board; private final List teleports; private final List players; @@ -15,7 +18,7 @@ public class BoardEntity { private GameMovementStrategy movementStrategy; - public BoardEntity(Board board, List teleports, List players, List dices) { + public GameController(Board board, List teleports, List players, List dices) { this.board = board; this.teleports = teleports; this.players = players; From ae589f8e1d27bffe0014a5f4131077cedd116763 Mon Sep 17 00:00:00 2001 From: "sanchit.sinha" Date: Mon, 3 Feb 2025 22:03:54 +0530 Subject: [PATCH 7/7] add splitwise implementation --- pom.xml | 1 + snakeAndLadder/pom.xml | 8 +- .../strategy/DiceMovementStrategyTest.java | 77 +++++++++++++++ splitWise/pom.xml | 20 ++++ .../java/org/machinecoding/Constants.java | 10 ++ .../src/main/java/org/machinecoding/Main.java | 97 +++++++++++++++++++ .../org/machinecoding/models/Expense.java | 21 ++++ .../org/machinecoding/models/Transaction.java | 43 ++++++++ .../java/org/machinecoding/models/User.java | 31 ++++++ .../org/machinecoding/models/UserPair.java | 35 +++++++ .../repository/BalanceRepository.java | 80 +++++++++++++++ .../repository/UserRepository.java | 22 +++++ .../services/SplitWiseRunner.java | 56 +++++++++++ .../strategy/EqualSplittingStrategy.java | 26 +++++ .../strategy/ExactSplittingStrategy.java | 32 ++++++ .../strategy/PercentageSplittingStrategy.java | 32 ++++++ .../strategy/SplittingStrategy.java | 7 ++ 17 files changed, 596 insertions(+), 2 deletions(-) create mode 100644 snakeAndLadder/src/test/java/org/machinecoding/strategy/DiceMovementStrategyTest.java create mode 100644 splitWise/pom.xml create mode 100644 splitWise/src/main/java/org/machinecoding/Constants.java create mode 100644 splitWise/src/main/java/org/machinecoding/Main.java create mode 100644 splitWise/src/main/java/org/machinecoding/models/Expense.java create mode 100644 splitWise/src/main/java/org/machinecoding/models/Transaction.java create mode 100644 splitWise/src/main/java/org/machinecoding/models/User.java create mode 100644 splitWise/src/main/java/org/machinecoding/models/UserPair.java create mode 100644 splitWise/src/main/java/org/machinecoding/repository/BalanceRepository.java create mode 100644 splitWise/src/main/java/org/machinecoding/repository/UserRepository.java create mode 100644 splitWise/src/main/java/org/machinecoding/services/SplitWiseRunner.java create mode 100644 splitWise/src/main/java/org/machinecoding/strategy/EqualSplittingStrategy.java create mode 100644 splitWise/src/main/java/org/machinecoding/strategy/ExactSplittingStrategy.java create mode 100644 splitWise/src/main/java/org/machinecoding/strategy/PercentageSplittingStrategy.java create mode 100644 splitWise/src/main/java/org/machinecoding/strategy/SplittingStrategy.java diff --git a/pom.xml b/pom.xml index 860e1b32..bd84550a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,5 +11,6 @@ snakeAndLadder + splitWise diff --git a/snakeAndLadder/pom.xml b/snakeAndLadder/pom.xml index 424f86a0..dd698886 100644 --- a/snakeAndLadder/pom.xml +++ b/snakeAndLadder/pom.xml @@ -4,9 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.machinecoding + + org.machinecoding + machineCoding-parent + 1.0-SNAPSHOT + + snakeAndLadder - 1.0-SNAPSHOT 23 diff --git a/snakeAndLadder/src/test/java/org/machinecoding/strategy/DiceMovementStrategyTest.java b/snakeAndLadder/src/test/java/org/machinecoding/strategy/DiceMovementStrategyTest.java new file mode 100644 index 00000000..9e21c5b6 --- /dev/null +++ b/snakeAndLadder/src/test/java/org/machinecoding/strategy/DiceMovementStrategyTest.java @@ -0,0 +1,77 @@ +package org.machinecoding.strategy; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.machinecoding.models.Dice; +import org.mockito.Mockito; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; + +class DiceMovementStrategyTest { + + private DiceMovementStrategy diceMovementStrategy; + private List mockDices; + + @BeforeEach + void setUp() { + mockDices = List.of(Mockito.mock(Dice.class), Mockito.mock(Dice.class)); + diceMovementStrategy = new DiceMovementStrategy(mockDices); + } + + // Test Scenario: Test the DiceMovementStrategy class to ensure it correctly implements the MovementStrategy interface, + // focusing on the move method's ability to calculate the new position based on dice rolls. + @ParameterizedTest + @CsvSource({ + "0, 3, 4, 7", + "5, 2, 6, 13", + "10, 1, 1, 12" + }) + void testMoveMethodCalculatesNewPosition(int initialPosition, int roll1, int roll2, int expectedPosition) { + when(mockDices.get(0).roll()).thenReturn(roll1); + when(mockDices.get(1).roll()).thenReturn(roll2); + + int newPosition = diceMovementStrategy.move(initialPosition); + + assertEquals(expectedPosition, newPosition); + } + + // Test Scenario: Test the move method with an empty list of dice to ensure it returns the initial position without changes. + @Test + void testMoveMethodWithEmptyDiceList() { + DiceMovementStrategy strategyWithNoDice = new DiceMovementStrategy(List.of()); + int initialPosition = 10; + + int newPosition = strategyWithNoDice.move(initialPosition); + + assertEquals(initialPosition, newPosition); + } + + // Test Scenario: Test the move method with maximum dice roll values to ensure it calculates the correct new position. + @Test + void testMoveMethodWithMaximumDiceRolls() { + when(mockDices.get(0).roll()).thenReturn(6); + when(mockDices.get(1).roll()).thenReturn(6); + int initialPosition = 0; + + int newPosition = diceMovementStrategy.move(initialPosition); + + assertEquals(12, newPosition); + } + + // Test Scenario: Test the move method with minimum dice roll values to ensure it calculates the correct new position. + @Test + void testMoveMethodWithMinimumDiceRolls() { + when(mockDices.get(0).roll()).thenReturn(1); + when(mockDices.get(1).roll()).thenReturn(1); + int initialPosition = 0; + + int newPosition = diceMovementStrategy.move(initialPosition); + + assertEquals(2, newPosition); + } +} \ No newline at end of file diff --git a/splitWise/pom.xml b/splitWise/pom.xml new file mode 100644 index 00000000..25abd6db --- /dev/null +++ b/splitWise/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + org.machinecoding + machineCoding-parent + 1.0-SNAPSHOT + + + splitWise + + + 23 + 23 + UTF-8 + + + \ No newline at end of file diff --git a/splitWise/src/main/java/org/machinecoding/Constants.java b/splitWise/src/main/java/org/machinecoding/Constants.java new file mode 100644 index 00000000..9aec1377 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/Constants.java @@ -0,0 +1,10 @@ +package org.machinecoding; + +public class Constants { + public static final String SHOW = "SHOW"; + public static final String EXPENSE = "EXPENSE"; + + public static final String EQUAL = "EQUAL"; + public static final String EXACT = "EXACT"; + public static final String PERCENTAGE = "PERCENT"; +} diff --git a/splitWise/src/main/java/org/machinecoding/Main.java b/splitWise/src/main/java/org/machinecoding/Main.java new file mode 100644 index 00000000..68326308 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/Main.java @@ -0,0 +1,97 @@ +package org.machinecoding; + +import org.machinecoding.models.Expense; +import org.machinecoding.models.User; +import org.machinecoding.services.SplitWiseRunner; +import org.machinecoding.strategy.EqualSplittingStrategy; +import org.machinecoding.strategy.ExactSplittingStrategy; +import org.machinecoding.strategy.PercentageSplittingStrategy; +import org.machinecoding.strategy.SplittingStrategy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; + +import static org.machinecoding.Constants.*; + +public class Main { + public static void main(String[] args) { + User user1 = new User("u1", "user1", "user1@gmail.com", "XXXXXXX"); + User user2 = new User("u2", "user2", "user2@gmail.com", "XXXXXXX"); + User user3 = new User("u3", "user3", "user3@gmail.com", "XXXXXXX"); + User user4 = new User("u4", "user4", "user3@gmail.com", "XXXXXXX"); + + SplitWiseRunner runner = new SplitWiseRunner(); + runner.addUser(user1); + runner.addUser(user2); + runner.addUser(user3); + runner.addUser(user4); + + Scanner scan = new Scanner(System.in); + while (scan.hasNextLine()) { + String command = scan.nextLine(); + processCommand(command, runner); + } + scan.close(); + } + + private static void processCommand(String command, SplitWiseRunner runner) { + String[] parts = command.split(" "); + String action = parts[0]; + + switch (action) { + case SHOW: + handleShowCommand(runner, parts); + break; + case EXPENSE: + handleExpenseCommand(runner, parts); + break; + default: + break; + } + } + + private static void handleExpenseCommand(SplitWiseRunner runner, String[] parts) { + String paidBy = parts[1]; + Double amount = Double.parseDouble(parts[2]); + + int len = Integer.parseInt(parts[3]); + List paidFor = new ArrayList<>(Arrays.asList(parts).subList(4, len + 4)); + + String expenseType = parts[len + 4]; + Expense expense = runner.createExpense(amount, getSplittingStrategy(expenseType, len, parts)); + runner.addTransaction(paidBy, paidFor, expense); + } + + private static SplittingStrategy getSplittingStrategy(String expenseType, int numUsers, String[] parts) { + switch (expenseType){ + case EQUAL: + return new EqualSplittingStrategy(numUsers); + case EXACT: + List splitAmt = new ArrayList<>(); + for(int i = 0; i < numUsers; i++) { + splitAmt.add(Double.parseDouble(parts[numUsers + 5 + i])); + } + return new ExactSplittingStrategy(splitAmt); + case PERCENTAGE: + List splitPercentage = new ArrayList<>(); + for(int i = 0; i < numUsers; i++) { + splitPercentage.add(Double.parseDouble(parts[numUsers + 5 + i])); + } + return new PercentageSplittingStrategy(splitPercentage); + default: + break; + } + + return null; + } + + private static void handleShowCommand(SplitWiseRunner runner, String[] parts) { + if (parts.length == 1) { + runner.getAllBalances(); + } else { + runner.getUserBalance(parts[1]); + } + } +} \ No newline at end of file diff --git a/splitWise/src/main/java/org/machinecoding/models/Expense.java b/splitWise/src/main/java/org/machinecoding/models/Expense.java new file mode 100644 index 00000000..035d9426 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/models/Expense.java @@ -0,0 +1,21 @@ +package org.machinecoding.models; + +import org.machinecoding.strategy.SplittingStrategy; + +public class Expense { + private Double amount; + private SplittingStrategy strategy; + + public Expense(Double amount, SplittingStrategy strategy) { + this.amount = amount; + this.strategy = strategy; + } + + public SplittingStrategy getStrategy() { + return strategy; + } + + public Double getAmount() { + return amount; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/models/Transaction.java b/splitWise/src/main/java/org/machinecoding/models/Transaction.java new file mode 100644 index 00000000..e0d1caae --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/models/Transaction.java @@ -0,0 +1,43 @@ +package org.machinecoding.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Transaction { + private User paidBy; + private List paidFor; + private Expense expense; + + private Map splits; // paidFor, Expense expense) { + this.paidBy = paidBy; + this.paidFor = paidFor; + this.expense = expense; + this.splits = new HashMap<>(); + } + + public void populateSplitMap() { + List splitAmount = expense.getStrategy().getSplit(expense.getAmount()); + for (int i = 0; i < paidFor.size(); i++) { + splits.put(paidFor.get(i), splitAmount.get(i)); + } + } + + public Map getSplits() { + return splits; + } + + public User getPaidBy() { + return paidBy; + } + + public List getPaidFor() { + return paidFor; + } + + public Expense getExpense() { + return expense; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/models/User.java b/splitWise/src/main/java/org/machinecoding/models/User.java new file mode 100644 index 00000000..9f053a34 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/models/User.java @@ -0,0 +1,31 @@ +package org.machinecoding.models; + +public class User { + private final String id; + private final String name; + private final String email; + private final String mobileNumber; + + public User(String id, String name, String email, String mobileNumber) { + this.mobileNumber = mobileNumber; + this.email = email; + this.name = name; + this.id = id; + } + + public String getMobileNumber() { + return mobileNumber; + } + + public String getEmail() { + return email; + } + + public String getName() { + return name; + } + + public String getId() { + return id; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/models/UserPair.java b/splitWise/src/main/java/org/machinecoding/models/UserPair.java new file mode 100644 index 00000000..78efe1eb --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/models/UserPair.java @@ -0,0 +1,35 @@ +package org.machinecoding.models; + +import java.util.Objects; + +public class UserPair { + private User user; + private User friend; + + public User getUser() { + return user; + } + + public User getFriend() { + return friend; + } + + public UserPair(User user, User friend) { + this.user = user; + this.friend = friend; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UserPair userPair = (UserPair) o; + return Objects.equals(user, userPair.user) && + Objects.equals(friend, userPair.friend); + } + + @Override + public int hashCode() { + return Objects.hash(user, friend); + } +} diff --git a/splitWise/src/main/java/org/machinecoding/repository/BalanceRepository.java b/splitWise/src/main/java/org/machinecoding/repository/BalanceRepository.java new file mode 100644 index 00000000..f42c3bee --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/repository/BalanceRepository.java @@ -0,0 +1,80 @@ +package org.machinecoding.repository; + +import org.machinecoding.models.User; +import org.machinecoding.models.UserPair; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public class BalanceRepository { + private Map userBalanceMap; + // a b (a -> b) => a owes b + + public BalanceRepository() { + this.userBalanceMap = new HashMap<>(); + } + + public void addUserBalance(UserPair pair, Double balance) { + balance = roundToTwoDecimalPlaces(balance); + + if (Objects.equals(pair.getFriend(), pair.getUser())) return; + if (userBalanceMap.containsKey(pair)) { + userBalanceMap.put(pair, userBalanceMap.get(pair) + balance); + } else { + userBalanceMap.put(pair, balance); + } + + // simplify transactions + UserPair pair2 = new UserPair(pair.getFriend(), pair.getUser()); + if (userBalanceMap.containsKey(pair2)) { + Double amt1 = userBalanceMap.get(pair); + Double amt2 = userBalanceMap.get(pair2); + + if (amt1 > amt2) { + userBalanceMap.put(pair, amt1 - amt2); + userBalanceMap.remove(pair2); + } else if (amt1 < amt2) { + userBalanceMap.put(pair2, amt2 - amt1); + userBalanceMap.remove(pair); + } else { + userBalanceMap.remove(pair); + userBalanceMap.remove(pair2); + } + } + } + + private Double roundToTwoDecimalPlaces(Double value) { + return Math.round(value * 100.0) / 100.0; + } + + public void getUserBalance(User user) { + boolean gotTransaction = false; + for (Map.Entry entry : userBalanceMap.entrySet()) { + User usr = entry.getKey().getUser(); + User frnd = entry.getKey().getFriend(); + if (Objects.equals(usr, user) || Objects.equals(frnd, user)) { + System.out.println(usr.getName() + " owes " + frnd.getName() + ": " + entry.getValue()); + gotTransaction = true; + } + } + + if (!gotTransaction) { + System.out.println("No balances"); + } + } + + public void getAllBalances() { + boolean gotTransaction = false; + for (Map.Entry entry : userBalanceMap.entrySet()) { + User usr = entry.getKey().getUser(); + User frnd = entry.getKey().getFriend(); + System.out.println(usr.getName() + " owes " + frnd.getName() + ": " + entry.getValue()); + gotTransaction = true; + } + + if (!gotTransaction) { + System.out.println("No balances"); + } + } +} diff --git a/splitWise/src/main/java/org/machinecoding/repository/UserRepository.java b/splitWise/src/main/java/org/machinecoding/repository/UserRepository.java new file mode 100644 index 00000000..c4450dee --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/repository/UserRepository.java @@ -0,0 +1,22 @@ +package org.machinecoding.repository; + +import org.machinecoding.models.User; + +import java.util.HashMap; +import java.util.Map; + +public class UserRepository { + private Map userMap; + + public UserRepository() { + userMap = new HashMap<>(); + } + + public void addUser(User user) { + userMap.put(user.getId(), user); + } + + public Map getUserMap() { + return userMap; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/services/SplitWiseRunner.java b/splitWise/src/main/java/org/machinecoding/services/SplitWiseRunner.java new file mode 100644 index 00000000..140cfe17 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/services/SplitWiseRunner.java @@ -0,0 +1,56 @@ +package org.machinecoding.services; + +import org.machinecoding.models.*; +import org.machinecoding.repository.BalanceRepository; +import org.machinecoding.repository.UserRepository; +import org.machinecoding.strategy.SplittingStrategy; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class SplitWiseRunner { + private BalanceRepository balanceRepository; + private UserRepository userRepository; + + public SplitWiseRunner(){ + this.balanceRepository = new BalanceRepository(); + this.userRepository = new UserRepository(); + } + + public void addUser(User user){ + userRepository.addUser(user); + } + + public Expense createExpense(Double amt, SplittingStrategy strategy){ + return new Expense(amt, strategy); + } + + public void addTransaction(String paidBy, List paidFor, Expense exp){ + User paidByUser = userRepository.getUserMap().get(paidBy); + List paidForUsers = paidFor.stream() + .map(u->userRepository.getUserMap().get(u)) + .collect(Collectors.toList()); + + Transaction transaction = new Transaction(paidByUser, paidForUsers, exp); + transaction.populateSplitMap(); + + addEntryInUserBalance(paidByUser, transaction); + } + + public void addEntryInUserBalance(User paidBy, Transaction transaction) { + for (Map.Entry entry : transaction.getSplits().entrySet()) { + balanceRepository.addUserBalance(new UserPair(entry.getKey(), paidBy), entry.getValue()); + } + } + + public void getAllBalances() { + balanceRepository.getAllBalances(); + } + + public void getUserBalance(String userId) { + balanceRepository.getUserBalance(userRepository.getUserMap().get(userId)); + } + +} diff --git a/splitWise/src/main/java/org/machinecoding/strategy/EqualSplittingStrategy.java b/splitWise/src/main/java/org/machinecoding/strategy/EqualSplittingStrategy.java new file mode 100644 index 00000000..5e340d98 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/strategy/EqualSplittingStrategy.java @@ -0,0 +1,26 @@ +package org.machinecoding.strategy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class EqualSplittingStrategy implements SplittingStrategy { + private final int numUsers; + + public EqualSplittingStrategy(int numUsers) { + this.numUsers = numUsers; + } + + @Override + public List getSplit(Double amount) { + List share = new ArrayList<>(); + for (int i = 0; i < numUsers; i++) { + share.add(roundToTwoDecimalPlaces(amount / numUsers)); + } + return share; + } + + private Double roundToTwoDecimalPlaces(Double value) { + return Math.round(value * 100.0) / 100.0; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/strategy/ExactSplittingStrategy.java b/splitWise/src/main/java/org/machinecoding/strategy/ExactSplittingStrategy.java new file mode 100644 index 00000000..2ebf5c29 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/strategy/ExactSplittingStrategy.java @@ -0,0 +1,32 @@ +package org.machinecoding.strategy; + +import java.util.List; +import java.util.stream.Collectors; + +public class ExactSplittingStrategy implements SplittingStrategy{ + List exactAmount; + + public ExactSplittingStrategy(List exactAmount) { + this.exactAmount = exactAmount; + } + + @Override + public List getSplit(Double amount) { + Double sum = 0.0; + for (Double i : exactAmount){ + sum += i; + } + + if(!sum.equals(amount)){ + throw new IllegalArgumentException("Sum of the amounts should be equal to total expense"); + } + + return exactAmount.stream() + .map(this::roundToTwoDecimalPlaces) + .collect(Collectors.toList()); + } + + private Double roundToTwoDecimalPlaces(Double value) { + return Math.round(value * 100.0) / 100.0; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/strategy/PercentageSplittingStrategy.java b/splitWise/src/main/java/org/machinecoding/strategy/PercentageSplittingStrategy.java new file mode 100644 index 00000000..d4ec0f1d --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/strategy/PercentageSplittingStrategy.java @@ -0,0 +1,32 @@ +package org.machinecoding.strategy; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class PercentageSplittingStrategy implements SplittingStrategy{ + List percentages; + + public PercentageSplittingStrategy(List percentages){ + this.percentages = percentages; + } + + @Override + public List getSplit(Double amount) { + Double sum = 0.0; + for (Double percentage : percentages) { + sum += percentage; + } + if(!sum.equals(100.0)){ + throw new IllegalArgumentException("Sum of percentage must be equal to 100"); + } + + return percentages.stream() + .map(t -> roundToTwoDecimalPlaces(t * amount / 100.00)) + .collect(Collectors.toList()); + } + + private Double roundToTwoDecimalPlaces(Double value) { + return Math.round(value * 100.0) / 100.0; + } +} diff --git a/splitWise/src/main/java/org/machinecoding/strategy/SplittingStrategy.java b/splitWise/src/main/java/org/machinecoding/strategy/SplittingStrategy.java new file mode 100644 index 00000000..28c5bb17 --- /dev/null +++ b/splitWise/src/main/java/org/machinecoding/strategy/SplittingStrategy.java @@ -0,0 +1,7 @@ +package org.machinecoding.strategy; + +import java.util.List; + +public interface SplittingStrategy { + List getSplit(Double amount); +}