Skip to content

Commit

Permalink
WIP step-4
Browse files Browse the repository at this point in the history
  • Loading branch information
balthaB committed Mar 12, 2024
1 parent 43d6a19 commit 2b9776a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/ch/epfl/chacun/ZonePartitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public record ZonePartitions(ZonePartition<Zone.Forest> forests, ZonePartition<Z
*/
public static final class Builder {
// The builder of the forests partition
private ZonePartition.Builder<Zone.Forest> forests;
private final ZonePartition.Builder<Zone.Forest> forests;
// The builder of the meadows partition
private ZonePartition.Builder<Zone.Meadow> meadows;
private final ZonePartition.Builder<Zone.Meadow> meadows;
// The builder of the rivers partition
private ZonePartition.Builder<Zone.River> rivers;
private final ZonePartition.Builder<Zone.River> rivers;
// The builder of the river systems partition
private ZonePartition.Builder<Zone.Water> riverSystems;
private final ZonePartition.Builder<Zone.Water> riverSystems;

/**
* Returns a new builder whose four partitions are initially identical to those of the given
Expand Down Expand Up @@ -82,7 +82,7 @@ public void addTile(Tile tile) {
}

/**
* Connects each other the two given tile sides by connecting the corresponding areas.
* Connects to each other the two given tile sides by connecting the corresponding areas.
*
* @param s1 the first tile side
* @param s2 the second tile side
Expand Down
21 changes: 21 additions & 0 deletions test/ch/epfl/chacun/ZonePartitionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,26 @@ void addTileWorks() {
testBuilder.addTile(tile);

assertEquals(expectedZonePartitions, testBuilder.build());

}

@Test
void connectSidesWorks() {
// Meadows
Zone.Meadow meadow1 = new Zone.Meadow(0, new ArrayList<>(List.of(new Animal(0
, Animal.Kind.AUROCHS))), null);
Zone.Meadow meadow2 = new Zone.Meadow(1, new ArrayList<>(), null);

TileSide.Meadow meadowSide1 = new TileSide.Meadow(meadow1);
TileSide.Meadow meadowSide2 = new TileSide.Meadow(meadow2);

Set<Zone.Meadow> meadows1 = Set.of(meadow1);
Set<Zone.Meadow> meadows2 = Set.of(meadow2);

Area<Zone.Meadow> meadowArea1 = new Area<>(meadows1, new ArrayList<>(), 1);
Area<Zone.Meadow> meadowArea2 = new Area<>(meadows2, new ArrayList<>(), 1);

ZonePartition<Zone.Meadow> meadowZonePartition = new ZonePartition<>(Set.of(meadowArea1, meadowArea2));
}

}

0 comments on commit 2b9776a

Please sign in to comment.