-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI valmis ja kattavat jUnit testit luotu
- Loading branch information
Showing
65 changed files
with
7,398 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/Tiralabra/nbproject/private/ | ||
/Tiralabra/build/ | ||
/Tiralabra/build/ | ||
/Tiralabra/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package GameMove; | ||
|
||
/** | ||
* Luokka voittaja tarkistukseen | ||
* @author Jomppa | ||
*/ | ||
public class Inspector { | ||
|
||
public Inspector() { | ||
|
||
} | ||
|
||
/** | ||
* Tarkistaa kömpelösti (atm) kumpi siirroista voittaa. | ||
* @param p1 player1 siirto | ||
* @param p2 player2 siirto | ||
*/ | ||
public String checkWhoWins(String p1, String p2) { | ||
if (p1.contains(p2)) { | ||
return "t"; | ||
} else if (p1.equals("k")) { | ||
if (p2.equals("s")) { | ||
return "p1"; | ||
} else { | ||
return "p2"; | ||
} | ||
} | ||
else if (p1.equals("s")) { | ||
if (p2.equals("p")) { | ||
return "p1"; | ||
} else { | ||
return "p2"; | ||
} | ||
} else if (p1.equals("p")) { | ||
if (p2.equals("k")) { | ||
return "p1"; | ||
} else { | ||
return "p2"; | ||
} | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package ArtificialIntelligence; | ||
|
||
import org.junit.Assert; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Jomppa | ||
*/ | ||
public class AITest { | ||
|
||
private AI ai = new AI(); | ||
|
||
public AITest() { | ||
|
||
} | ||
/** | ||
* Testataan valitseeko tekoäly siirroksi k, p tai s | ||
*/ | ||
@Test | ||
public void canAIMakeMoveK() { | ||
String move = ai.getMove()+""; | ||
if (move.equals("k") || move.equals("s") || move.equals("p")) { | ||
|
||
assertFalse("".contains(move)); | ||
} else { | ||
assertFalse("I didnt make k, p or s :(", move.contains("")); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package GameMove; | ||
|
||
import Player.Player; | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Jomppa | ||
*/ | ||
public class InspectorTest { | ||
|
||
private Inspector inspa = new Inspector(); | ||
|
||
public InspectorTest() { | ||
|
||
} | ||
|
||
/** | ||
* Testataan toimiiko p1 voiton selvitys | ||
*/ | ||
@Test | ||
public void doInspGetWinner() { | ||
assertEquals("p1", inspa.checkWhoWins("k", "s")); | ||
} | ||
|
||
/** | ||
* Testataan toimiiko p1 tasurin selvitys | ||
*/ | ||
@Test | ||
public void doInspGetTie() { | ||
assertEquals("t", inspa.checkWhoWins("s", "s")); | ||
} | ||
|
||
/** | ||
* Testataan toimiiko p1 häviön selvitys | ||
*/ | ||
@Test | ||
public void doInspGetLoser() { | ||
assertEquals("p2", inspa.checkWhoWins("s", "k")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package Player; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Jomppa | ||
*/ | ||
public class PlayerTest { | ||
private Player p1 = new Player(); | ||
|
||
public PlayerTest () { | ||
p1.setName("Matti"); | ||
|
||
} | ||
/** | ||
* Testataan toimiiko getName | ||
*/ | ||
@Test | ||
public void isNameRight() { | ||
assertEquals("Matti" , p1.getName()); | ||
} | ||
|
||
/** | ||
* Testataan toimiiko pisteiden kasvatus | ||
*/ | ||
@Test | ||
public void pointsAreGrowing() { | ||
p1.addPoint(); | ||
assertEquals(1 , p1.getPoints()); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.