Skip to content

Commit

Permalink
Merge branch 'main' into manual_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
NCsab01 authored May 22, 2024
2 parents 5fa7518 + 5080094 commit 2ead642
Show file tree
Hide file tree
Showing 22 changed files with 1,807 additions and 332 deletions.
1 change: 0 additions & 1 deletion Drumakomi_sivatag/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@
</plugin>
</plugins>
</build>

</project>
645 changes: 340 additions & 305 deletions Drumakomi_sivatag/src/main/java/Game.java

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Drumakomi_sivatag/src/main/java/Mechanic.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public Mechanic(int id,int cm,Element e){
public int getPumpes() {
return pumpes;
}

public void setPumpes(int pumpesnumber) {
this.pumpes = pumpesnumber;
}

/**
* A pumpnak amin a szerelo al allitja at az inputjat es outputjat
* @param i Az elemnek amin allunk az i-edik szomszedja
Expand Down
30 changes: 17 additions & 13 deletions Drumakomi_sivatag/src/main/java/Mountains.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
/**
* Ahonnan folyik a jatek soran a viz (kezdoallomas)
*/
//Csaba
// Csaba
public class Mountains extends Node {

/**
* Konstruktor
*/
public Mountains() {
//PipeSystem.getViews().put(this, new MountainsView());
// PipeSystem.getViews().put(this, new MountainsView());
}

/**
* Segitsegevel a Mountains class, illetve a fuggvenyei az ido fuggvenyeben kepesek
* Segitsegevel a Mountains class, illetve a fuggvenyei az ido fuggvenyeben
* kepesek
* cselekedni
*/
@Override
public void TimerNotify(){
counter=1;
public void TimerNotify() {
counter = 1;
this.Path(null);
}

/**
* Meghivja a kovetkezo elem Path-jet (a viz folyasat hivatott jelezni).
*
* @param e - A cso ahonnan jon a viz
*/
public void Path(Element e){
if(counter==1) {
public void Path(Element e) {
if (counter == 1) {
System.out.println("Mountains");
counter++;
for (Element neighbour : this.neighbours) {
if(neighbour!=null){
if (neighbour != null) {
neighbour.Path(this);
}
}
}
}

/**
*
* Mountainsrol kiirja a fontosabb adatokat
*/
public void Info(){
*
* Mountainsrol kiirja a fontosabb adatokat
*/
public void Info() {
System.out.println("Mountains info:");
System.out.println("Hozza kapcsolodo csovek szama: " + this.neighbours.size());
super.Info();
}

/**
* Visszaadja a benne talalhato vizet.
*
* @return Integer.MAX_VALUE
*/
public int GetStorage() {
Expand All @@ -57,10 +61,10 @@ public int GetStorage() {
/**
* Felul irja az elment SetStorage-et.
* Azert nem csinal semmit, mert vegtelen sok viz van benne minden idopontban.
*
* @param n Az uj storage ertek
*/
public void SetStorage(int n) {
// Mivel vegtelen sok viz van benne minden idopontban, itt nincs ertelme allitani a vizmennyiseget.
}
}

16 changes: 15 additions & 1 deletion Drumakomi_sivatag/src/main/java/Pipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ public boolean CutPipe() {
System.out.println("Nincs nalad pumpa ahhoz, hogy a csovet ketto tudd fureszelni");
return false;
}

public void setDamaged(boolean b) {
damaged = b;
}
Expand All @@ -466,5 +465,20 @@ public void setStucky(int i) {

public void setSlippery(int i) {
slippery = i;
// For tests
public void AddPlayer(Player p) {
player.add(p);
}

public void SetStuckyValue(int newValue) {
stucky = newValue;
}

public void SetSlipperyValue(int newValue) {
slippery = newValue;
}

public void SetNotDamageable(int newValue) {
notDamageable = newValue;
}
}
5 changes: 5 additions & 0 deletions Drumakomi_sivatag/src/main/java/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public void setCantMove(int cantMove) {
this.cantMove = cantMove;
}

public int getcantMove(){
return cantMove;
}


/**
* Beallitja a player element attributumat
*
Expand Down
17 changes: 17 additions & 0 deletions Drumakomi_sivatag/src/main/java/Pump.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,21 @@ public boolean detachPipe(Pipe p) {
neighbours.remove(p);
return true;
}
/**
* Visszaadja a pumpa bemeneti csovet
*
* @return - a bemeneti cso
*/
public Pipe getInput() {
return input;
}

/**
* Visszaadja a pumpa kimeneti csovet
*
* @return - a kimeneti cso
*/
public Pipe getOutput() {
return output;
}
}
85 changes: 85 additions & 0 deletions Drumakomi_sivatag/src/test/java/CisternsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

class CisternsTest {
private Cisterns cisterns;
private PipeSystem pipeSystem;
private Game game;

@BeforeEach
public void init() {
cisterns = new Cisterns();
pipeSystem = mock(PipeSystem.class);
game = mock(Game.class);
}

@Test
void PickUpPump() {
cisterns.CreatePump();
cisterns.PickUpPump();
assertEquals(0, cisterns.getAvailablePumps());
}

@Test
void CreatePumpCreatesNewPump() {
cisterns.CreatePump();
assertEquals(1, cisterns.getAvailablePumps());
}

@Test
void CreatePipeCreatesNewPipe() {
cisterns.CreatePipe();
assertEquals(1, cisterns.neighbours.size());
}

@Test
void CreatePipeCreatesNewPipeWithNeighbour() {
cisterns.CreatePipe();
assertEquals(cisterns, cisterns.neighbours.get(0).neighbours.get(0));
}

@Test
void CantPickUpPumpIfNoPumpsAvailable() {
cisterns.PickUpPump();
assertEquals(0, cisterns.getAvailablePumps());
}

@Test
void CisternsAddsWaterForMechnaics() {
cisterns.AddMWater(5);
verify(pipeSystem,times(1)).incMWater(5);
}

@Test
void AfterRandomTimeAPipeIsCreated() {
int size = cisterns.neighbours.size();
cisterns.TimerNotify();
if(size == cisterns.neighbours.size()) {
AfterRandomTimeAPipeIsCreated();
}
assertEquals(1, cisterns.neighbours.size());
}

@Test
void AfterRandomTimeAPumpIsCreated() {
int size = cisterns.getAvailablePumps();
cisterns.TimerNotify();
if(size == cisterns.getAvailablePumps()) {
AfterRandomTimeAPumpIsCreated();
}
assertEquals(1, cisterns.getAvailablePumps());
}

@Test
void WaterAddedToCisterns() {
Pipe pipe = mock(Pipe.class);
when(pipe.GetStorage()).thenReturn(10);
cisterns.Path(pipe);
verify(pipe,times(1)).SetStorage(0);
}
}
Loading

0 comments on commit 2ead642

Please sign in to comment.