Finished first functioning and successful unit test (tests noise handling)

This commit is contained in:
Alexander Sazonov
2022-04-28 13:25:03 +02:00
parent f37597a5cd
commit 93b6bab957
3 changed files with 56 additions and 4 deletions

View File

@@ -15,15 +15,13 @@ public class NoiseHandler {
* predator infecting a victim, so if there are already multiple ghosts in the game, the method
* should be called for each of them individually.
* @param passengers passengers of the train the game is played in
* @param predator ghost that has infected a human player during this night (called upon as
* passenger for convenience reasons)
* @param victim human player who has been turned into a ghost this night
* @param noiseAmount array containing information about how many times each passenger heard a noise this night
* @param game current game instance
* @return updated array with info on who heard how many noises
*/
public int[] noiseNotifier(Passenger[] passengers, Passenger predator, Passenger victim, int[] noiseAmount, Game game) {
public int[] noiseNotifier(Passenger predator, Passenger victim, int[] noiseAmount) {
if (predator.getPosition() - victim.getPosition()
> 0) { // if predator is to the right of victim
for (int i = predator.getPosition() - 1; i > victim.getPosition(); i--) {

View File

@@ -97,7 +97,7 @@ public class VoteHandler {
for (int i = 0; i < passengers.length; i++) {
if (passengers[i].getIsGhost() && i != ghostPosition) {
NoiseHandler n = new NoiseHandler();
noiseAmount = n.noiseNotifier(passengers, passengers[i], g, noiseAmount, game);
noiseAmount = n.noiseNotifier(passengers[i], g, noiseAmount);
}
}
for (int i = 0; i < passengers.length; i++) {