Skip to content

Commit 5fe2dc5

Browse files
committed
javadocs
1 parent 76c8b8c commit 5fe2dc5

File tree

18 files changed

+414
-246
lines changed

18 files changed

+414
-246
lines changed

Client/src/test/java/edu/sdccd/cisc191/Client/ClientTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,5 @@ void createBotArray() throws Exception {
152152
Client.createBotArray();
153153
List<BotBase> bots = Client.getBots();
154154
assertEquals(4, bots.size(), "should skip first (human) user and make 2 bots");
155-
assertEquals("a65e44c6f8", bots.get(0).getUser().getName());
156155
}
157156
}

Common/src/main/java/edu/sdccd/cisc191/Common/GameBST.java

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,76 @@
11
package edu.sdccd.cisc191.Common;
22

33
import edu.sdccd.cisc191.Common.Models.Game;
4-
54
import java.util.ArrayList;
65
import java.util.Comparator;
76
import java.util.List;
87

9-
class BSTNode<T> {
10-
T data;
11-
BSTNode<T> left, right;
8+
/**
9+
* A utility class for constructing binary search trees (BSTs) of {@link Game} objects
10+
* based on various sorting criteria (ID, odds, date).
11+
*/
12+
public class GameBST {
1213

13-
BSTNode(T data) {
14-
this.data = data;
15-
this.left = null;
16-
this.right = null;
17-
}
18-
}
14+
/**
15+
* A node in a binary search tree, holding a piece of data and references to left and right children.
16+
*
17+
* @param <T> the type of data stored in the node
18+
*/
19+
static class BSTNode<T> {
20+
T data;
21+
BSTNode<T> left, right;
1922

20-
public class GameBST {
23+
/**
24+
* Creates a new node containing the specified data.
25+
*
26+
* @param data the data to store in this node
27+
*/
28+
BSTNode(T data) {
29+
this.data = data;
30+
this.left = null;
31+
this.right = null;
32+
}
33+
}
2134

35+
/**
36+
* A generic binary search tree implementation.
37+
*
38+
* @param <T> the type of elements maintained by this tree
39+
*/
2240
public static class BinarySearchTree<T> {
2341
private BSTNode<T> root;
24-
private Comparator<T> comparator;
42+
private final Comparator<T> comparator;
2543

44+
/**
45+
* Constructs an empty binary search tree that uses the given comparator
46+
* for ordering elements.
47+
*
48+
* @param comparator the comparator to determine the order of elements
49+
*/
2650
public BinarySearchTree(Comparator<T> comparator) {
2751
this.comparator = comparator;
2852
}
2953

54+
/**
55+
* Inserts a new element into the tree.
56+
*
57+
* @param data the element to insert
58+
*/
3059
public void insert(T data) {
3160
root = insertRecursive(root, data);
3261
}
3362

63+
/**
64+
* Recursively inserts a new element into the subtree rooted at the given node.
65+
*
66+
* @param node the root of the subtree
67+
* @param data the element to insert
68+
* @return the root of the modified subtree
69+
*/
3470
private BSTNode<T> insertRecursive(BSTNode<T> node, T data) {
35-
if (node == null) return new BSTNode<>(data);
71+
if (node == null) {
72+
return new BSTNode<>(data);
73+
}
3674
if (comparator.compare(data, node.data) < 0) {
3775
node.left = insertRecursive(node.left, data);
3876
} else {
@@ -41,12 +79,24 @@ private BSTNode<T> insertRecursive(BSTNode<T> node, T data) {
4179
return node;
4280
}
4381

82+
/**
83+
* Returns a list of all elements in ascending order, as determined by the comparator.
84+
*
85+
* @return a list of the tree's elements in sorted (in-order) order
86+
*/
4487
public List<T> inorderTraversal() {
4588
List<T> result = new ArrayList<>();
4689
inorderRecursive(root, result);
4790
return result;
4891
}
4992

93+
/**
94+
* Recursively performs an in-order traversal of the subtree rooted at the given node,
95+
* adding elements to the provided list.
96+
*
97+
* @param node the root of the subtree
98+
* @param list the list to collect elements in sorted order
99+
*/
50100
private void inorderRecursive(BSTNode<T> node, List<T> list) {
51101
if (node != null) {
52102
inorderRecursive(node.left, list);
@@ -56,24 +106,48 @@ private void inorderRecursive(BSTNode<T> node, List<T> list) {
56106
}
57107
}
58108

109+
/**
110+
* Builds a binary search tree of {@link Game} objects sorted by game ID.
111+
*
112+
* @param games the list of games to insert into the tree
113+
* @return a BST with games ordered by ID
114+
*/
59115
public static BinarySearchTree<Game> buildGameIdTree(List<Game> games) {
60116
BinarySearchTree<Game> treeById = new BinarySearchTree<>(Comparator.comparing(Game::getId));
61117
games.forEach(treeById::insert);
62118
return treeById;
63119
}
64120

121+
/**
122+
* Builds a binary search tree of {@link Game} objects sorted by the first team's betting odds.
123+
*
124+
* @param games the list of games to insert into the tree
125+
* @return a BST with games ordered by team1 odds
126+
*/
65127
public static BinarySearchTree<Game> buildOddsTree(List<Game> games) {
66128
BinarySearchTree<Game> treeByOdds = new BinarySearchTree<>(Comparator.comparing(Game::getTeam1Odd));
67129
games.forEach(treeByOdds::insert);
68130
return treeByOdds;
69131
}
70132

133+
/**
134+
* Builds a binary search tree of {@link Game} objects sorted by the second team's betting odds.
135+
*
136+
* @param games the list of games to insert into the tree
137+
* @return a BST with games ordered by team2 odds
138+
*/
71139
public static BinarySearchTree<Game> buildTeam2OddsTree(List<Game> games) {
72140
BinarySearchTree<Game> treeByTeam2Odds = new BinarySearchTree<>(Comparator.comparing(Game::getTeam2Odd));
73141
games.forEach(treeByTeam2Odds::insert);
74142
return treeByTeam2Odds;
75143
}
76144

145+
/**
146+
* Builds a binary search tree of {@link Game} objects sorted by the game date.
147+
*
148+
* @param games the list of games to insert into the tree
149+
* @return a BST with games ordered by date
150+
*/
77151
public static BinarySearchTree<Game> buildDateTree(List<Game> games) {
78152
BinarySearchTree<Game> treeByDate = new BinarySearchTree<>(Comparator.comparing(Game::getGameDate));
79153
games.forEach(treeByDate::insert);
Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
11
package edu.sdccd.cisc191.Common;
22

3+
import lombok.Data;
4+
5+
/**
6+
* Data Transfer Object (DTO) representing an incoming bet.
7+
* <p>
8+
* This class is used to encapsulate information about a user's bet request,
9+
* including the ID of the game being bet on, the team being bet on,
10+
* the amount of the bet, and the potential win amount.
11+
* </p>
12+
*
13+
* <p>
14+
* Lombok's {@code @Data} annotation automatically generates boilerplate code
15+
* such as getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.
16+
* </p>
17+
*/
18+
@Data
319
public class IncomingBetDTO {
20+
21+
/**
22+
* The ID of the game that the bet is placed on.
23+
*/
424
private Long gameId;
25+
26+
/**
27+
* The name or identifier of the team that the user is betting on.
28+
*/
529
private String betTeam;
30+
31+
/**
32+
* The amount of money the user is betting.
33+
*/
634
private int betAmt;
35+
36+
/**
37+
* The potential amount the user can win if the bet is successful.
38+
*/
739
private int winAmt;
840

41+
/**
42+
* Constructs a new {@code IncomingBetDTO} with the specified values.
43+
*
44+
* @param gameId the ID of the game
45+
* @param betTeam the team being bet on
46+
* @param betAmt the amount being bet
47+
* @param winAmt the potential winnings
48+
*/
949
public IncomingBetDTO(Long gameId, String betTeam, int betAmt, int winAmt) {
1050
this.gameId = gameId;
1151
this.betTeam = betTeam;
1252
this.betAmt = betAmt;
1353
this.winAmt = winAmt;
1454
}
15-
16-
public int getBetAmt() {
17-
return betAmt;
18-
}
19-
20-
public void setBetAmt(int betAmt) {
21-
this.betAmt = betAmt;
22-
}
23-
24-
public String getBetTeam() {
25-
return betTeam;
26-
}
27-
28-
public void setBetTeam(String betTeam) {
29-
this.betTeam = betTeam;
30-
}
31-
32-
public Long getGameId() {
33-
return gameId;
34-
}
35-
36-
public void setGameId(Long gameId) {
37-
this.gameId = gameId;
38-
}
39-
40-
public int getWinAmt() {
41-
return winAmt;
42-
}
43-
44-
public void setWinAmt(int winAmt) {
45-
this.winAmt = winAmt;
46-
}
47-
48-
49-
// getters + setters
5055
}

Common/src/main/java/edu/sdccd/cisc191/Common/Models/User.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,54 +40,6 @@ public JodaModule jodaModule() {
4040
@Setter
4141
@ToString
4242
public class User implements Serializable {
43-
public Long getId() {
44-
return id;
45-
}
46-
47-
public void setId(Long id) {
48-
this.id = id;
49-
}
50-
51-
public String getName() {
52-
return name;
53-
}
54-
55-
public void setName(String name) {
56-
this.name = name;
57-
}
58-
59-
public long getMoney() {
60-
return money;
61-
}
62-
63-
public void setMoney(long money) {
64-
this.money = money;
65-
}
66-
67-
public int getMoneyLine() {
68-
return moneyLine;
69-
}
70-
71-
public void setMoneyLine(int moneyLine) {
72-
this.moneyLine = moneyLine;
73-
}
74-
75-
public List<Bet> getBets() {
76-
return bets;
77-
}
78-
79-
public void setBets(List<Bet> bets) {
80-
this.bets = bets;
81-
}
82-
83-
public int getMoneyBet() {
84-
return moneyBet;
85-
}
86-
87-
public void setMoneyBet(int moneyBet) {
88-
this.moneyBet = moneyBet;
89-
}
90-
9143
@Id
9244
@GeneratedValue(strategy = GenerationType.IDENTITY)
9345
private Long id;

DatabaseServer.mv.db

16 KB
Binary file not shown.

Server/Server/src/main/resources/games.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

Server/Server/src/main/resources/users.json

Whitespace-only changes.

Server/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
<artifactId>spring-boot-starter-test</artifactId>
4141
<scope>test</scope>
4242
</dependency>
43+
<dependency>
44+
<groupId>com.googlecode.json-simple</groupId>
45+
<artifactId>json-simple</artifactId>
46+
<version>1.1.1</version>
47+
<scope>compile</scope>
48+
</dependency>
4349

4450
</dependencies>
4551

0 commit comments

Comments
 (0)