+ 1
Can someone help me to solve this solver class?(what a fantastic linguitsic joke right🙊)
i will Post the given Code in comment Section because its a bit longer than the decriptions cap i will learn the topic firstly at friday at university and i wanna do this exercise earlier, but i am stuck i Could need advice , Resolution, Code .. Just anything :/ thanks
1 Odpowiedź
0
public class Solver {
public static int countFirstTrue;
public static int countFirstFalse;
public static int countLoopRun;
public static int countSecondTrue;
public static int countSecondFalse;
public static void reset() {
countFirstTrue = 0;
countFirstFalse = 0;
countLoopRun = 0;
countSecondTrue = 0;
countSecondFalse = 0;
}
public static void firstTrue() {
++countFirstTrue;
}
public static void firstFalse() {
++countFirstFalse;
}
public static void loopRun() {
++countLoopRun;
}
public static void secondTrue() {
++countSecondTrue;
}
public static void secondFalse() {
++countSecondFalse;
}
public static int solve(int x, int y) {
if (x < 0 || x >= 10 || y < 0 || y >= 10) {
firstTrue();
return -1;
} else {
firstFalse();
while (y != 0) {
loopRun();
int t = y;
y = x % y;
x = t;
}
if (x == 3) {
secondTrue();
return -2;
} else {
secondFalse();
return y;
}
}
}
}
*******now here is what i have to do:
public class SolverTest {
public static void test0() {
// TODO: One solve() call, which triggers one firstFalse call and one secondTrue call
}
public static void test1() {
// TODO: One solve() call, which triggers one firstTrue call
}
public static void test7() {
// TODO: One solve() call, which triggers one firstFalse call, two or more loopRun calls and one secondTrue call
}