aboutsummaryrefslogtreecommitdiff
path: root/challenge-323/deadmarshal/java/Ch1.java
blob: d83355c039e0819a869d96526c81ce9136c286ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Ch1 {
  public static void main(String[] args) {
    System.out.println(increment_decrement(new String[]{"--x", "x++", "x++"}));
    System.out.println(increment_decrement(new String[]{"x++", "++x", "x++"}));
    System.out.println(increment_decrement(new String[]{"x++", "++x", "--x", "x--"}));
  }

  private static int increment_decrement(String[] arr) {
    int x = 0;
    for (String s : arr) {
      if (s.contains("++")) x++;
      else x--;
    }
    return x;
  }
}