Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .idea/EvolutionGenerator.iml

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

10 changes: 10 additions & 0 deletions .idea/compiler.xml

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

11 changes: 11 additions & 0 deletions .idea/libraries/Gradle__org_apiguardian_apiguardian_api_1_1_2.xml

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

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

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

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

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

11 changes: 11 additions & 0 deletions .idea/libraries/Gradle__org_opentest4j_opentest4j_1_2_0.xml

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

6 changes: 1 addition & 5 deletions .idea/misc.xml

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

3 changes: 3 additions & 0 deletions .idea/modules.xml

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

12 changes: 12 additions & 0 deletions .idea/modules/oolab.iml

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

12 changes: 12 additions & 0 deletions .idea/modules/oolab.main.iml

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

18 changes: 18 additions & 0 deletions .idea/modules/oolab.test.iml

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

4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/AbstractAnimal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public abstract class AbstractAnimal implements IMapElement{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/AbstractMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public abstract class AbstractMap {
}
4 changes: 0 additions & 4 deletions oolab/src/main/java/agh/ics/oop/Animal.java

This file was deleted.

67 changes: 67 additions & 0 deletions oolab/src/main/java/agh/ics/oop/Direction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package agh.ics.oop;

public enum Direction {
NORTH,
EASTNORTH,
EAST,
EASTSOUTH,
SOUTH,
WESTSOUTH,
WEST,
WESTNORTH;
public Vector2d toUnitVector(){
return switch(this){
case NORTH -> new Vector2d(0,1);
case EASTNORTH -> new Vector2d(1,1);
case EAST -> new Vector2d(1,0);
case EASTSOUTH -> new Vector2d(1,-1);
case SOUTH -> new Vector2d(0,-1);
case WESTSOUTH -> new Vector2d(-1,-1);
case WEST -> new Vector2d(-1,0);
case WESTNORTH -> new Vector2d(-1,1);
default -> null;
};
}

public int toNumber(){
return switch(this){
case NORTH -> 0;
case EASTNORTH -> 1;
case EAST -> 2;
case EASTSOUTH -> 3;
case SOUTH -> 4;
case WESTSOUTH -> 5;
case WEST -> 6;
case WESTNORTH -> 7;
};
}

public Direction add(Direction d){
int sumInt=this.toNumber()+d.toNumber();
return switch(sumInt%8){
case 0 -> NORTH;
case 1 -> EASTNORTH;
case 2 -> EAST;
case 3 -> EASTSOUTH;
case 4 -> SOUTH;
case 5 -> WESTSOUTH;
case 6 -> WEST;
case 7 -> WESTNORTH;
default -> this;
};
}
public Direction add(int n){
int sumInt=this.toNumber()+n;
return switch(sumInt%8){
case 0 -> NORTH;
case 1 -> EASTNORTH;
case 2 -> EAST;
case 3 -> EASTSOUTH;
case 4 -> SOUTH;
case 5 -> WESTSOUTH;
case 6 -> WEST;
case 7 -> WESTNORTH;
default -> this;
};
}
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/ForestedEquators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class ForestedEquators implements IHolyGardener{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/GlobMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class GlobMap extends AbstractMap{
}
2 changes: 1 addition & 1 deletion oolab/src/main/java/agh/ics/oop/Grass.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package agh.ics.oop;

public class Grass {
public class Grass implements IMapElement{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/HellMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class HellMap extends AbstractMap{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/HijinksEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class HijinksEngine implements ISimulationEngine{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/IHolyGardener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public interface IHolyGardener {
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/IMapElement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public interface IMapElement {
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/ISimulationEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public interface ISimulationEngine {
}
4 changes: 0 additions & 4 deletions oolab/src/main/java/agh/ics/oop/MoveDirection.java

This file was deleted.

4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/PredestinationEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class PredestinationEngine implements ISimulationEngine{
}
4 changes: 4 additions & 0 deletions oolab/src/main/java/agh/ics/oop/ToxicCorpses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package agh.ics.oop;

public class ToxicCorpses implements IHolyGardener{
}
60 changes: 60 additions & 0 deletions oolab/src/main/java/agh/ics/oop/Vector2d.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package agh.ics.oop;

import java.util.Objects;

public class Vector2d{
public final int x;
public final int y;

public Vector2d (int x, int y){
this.x=x;
this.y=y;
}


public String toString() {
return "(%d, %d)".formatted(x, y);
}

public boolean precedes(Vector2d other) {
return x <= other.x && y <= other.y;
}

public boolean follows(Vector2d other) {
return x >= other.x && y >= other.y;
}

public Vector2d add(Vector2d other) {
return new Vector2d(x + other.x, y + other.y);
}

public Vector2d subtract(Vector2d other) {
return new Vector2d(x - other.x, y - other.y);
}

public Vector2d upperRight(Vector2d other) {
return new Vector2d(Math.max(x, other.x), Math.max(y, other.y));
}

public Vector2d lowerLeft(Vector2d other) {
return new Vector2d(Math.min(x, other.x), Math.min(y, other.y));
}

public Vector2d opposite() {
return new Vector2d(-x, -y);
}

@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Vector2d other = (Vector2d) obj;
return (x == other.x && y == other.y);
}

@Override
public int hashCode() {
return Objects.hash(x, y);
}
}