Advertisement
drorgrebel

MAMAN_14_Tester_ALL

Jan 26th, 2017
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.01 KB | None | 0 0
  1. /**
  2. * Write a description of class Ex14_Tester here.
  3. *
  4. * @author (dror)
  5. * @version (a version number or a date)
  6. */
  7.  
  8. import java.util.Random;
  9. import java.util.Scanner;
  10. public class Ex14_Tester_All
  11. {
  12. /* Set private variables to confige the simulation */
  13. //choose testers: "true" for tester to run
  14. private static boolean TESTER_0 = true; // The students tester
  15. private static boolean TESTER_1 = true; // Tester for question-1
  16. private static boolean TESTER_2 = true; // Tester for question-2
  17. private static boolean TESTER_3 = true; // Tester for question-3
  18. private static boolean TESTER_4 = true; // Tester for question-4
  19.  
  20. //set printouts for the testers (not including the students tester)
  21. private static boolean printouts_1 = true;
  22. private static boolean printouts_2 = true;
  23. private static boolean printouts_3 = true;
  24. private static boolean printouts_4 = true;
  25.  
  26. //set LOOPS for each tester (only for tesetrs 1-4)
  27. private static int LOOP_TESTER_1 = 1000;
  28. private static int LOOP_TESTER_2 = 1000;
  29. private static int LOOP_TESTER_3 = 1000;
  30. private static int LOOP_TESTER_4 = 1000;
  31. /* End of configure section */
  32.  
  33. private static int f (int[]a, int low, int high)
  34. {
  35. int res = 0;
  36. for (int i=low; i<=high; i++)
  37. res += a[i];
  38. return res;
  39. }
  40.  
  41. public static int what_org (int []a)
  42. {
  43. int temp = 0;
  44. for (int i=0; i<a.length; i++)
  45. {
  46. for (int j=i; j<a.length; j++)
  47. {
  48. int c = f(a, i, j);
  49. if (c%3 == 0)
  50. {
  51. if (j-i+1 > temp)
  52. temp = j-i+1;
  53. }
  54. }
  55. }
  56. return temp;
  57. }//End Original what
  58.  
  59. /* seroDistanceItr
  60. * An Iterative method to calculate distance of '1' from nearest '0' in a[]
  61. */
  62. public static int[] zeroDistanceItr(int []bin_array){
  63. //Create a new int[] array to contain the distances of '1' from '0' in bin_array[]
  64. int[] distances_array = new int[bin_array.length];
  65.  
  66. //Parse from left to right.
  67. //When encounter the first zero, start to calculate + write cells with the distance.
  68. //0 are not effected
  69. int zero_indx = -1; //zero isn't found yet
  70. int distance = -1; //initial value for distance. need to be positive
  71. int zero_counter = 0; //counts number of '0'
  72. for(int i=0; i< bin_array.length; i++){
  73. //if encounter a cell with '0':
  74. if( bin_array[i] == 0){
  75. distances_array[i] = 0;// '0' remains
  76. zero_indx = i;
  77. zero_counter++;
  78. }
  79. //calculate the distance and replace '1' with the value of distance
  80. else if( bin_array[i] != 0){//should have a distance instead of 1
  81. distance = i-zero_indx; //calculate distance from the last zero encountered
  82. distances_array[i] = distance;
  83. }
  84. }
  85. //Parse bin_array[] from right to left.
  86. //replace the distance only after first zero is encountered from left.
  87. //Also, replace the distanc eonly if distance is smaller than th ewritten distance.
  88. zero_indx = -1; //initiate zero_indx before parsing from left to right
  89. distance = -1; //initial value for distance. need to be positive
  90. for(int i=bin_array.length-1; i>=0; i--){
  91. //if encounter a cell with '0':
  92. if( bin_array[i] == 0){
  93. distances_array[i] = 0;// '0' remains
  94. zero_indx = i;
  95. zero_counter--;
  96. }
  97. //calculate the distance and replace '1' with the value of distance, if new distance is smaller than the written one
  98. else if( (bin_array[i] != 0)&&(zero_indx != -1) ){//calculate distance only after encountering the first zero from left
  99. distance = zero_indx - i; //calculate distance from the last zero encountered (zero is on the left)
  100. //only if last zero is still ahead (when parsing left to right)
  101. if( (distance < distances_array[i])&&(zero_counter>0) ){//if no '0' ahead, the distance is
  102. distances_array[i] = distance;
  103. }
  104. //if no more zero's ahead (when parsing left to right)--> write the distance
  105. else if(zero_counter == 0){
  106. distances_array[i] = distance;
  107. }
  108. }
  109. }
  110. return distances_array;
  111. }//End zeroDistanceItr
  112.  
  113.  
  114. /*
  115. * private method to find iteratively if a string t is a transtormation of string s
  116. */
  117. private static boolean isTransItr(String s, String t)
  118. {
  119. int s_pt = 0; //pointer starts to check at indx 0
  120. int t_pt = 0; //pointer starts to check at indx 0
  121. if( s.equals("") && t.equals("")){
  122. return true;
  123. }
  124. else if( s.equals("") || t.equals("")){
  125. return false;
  126. }
  127. //compare the first character of the two strings
  128. else if( s.length() > t.length()){
  129. return false;
  130. }
  131. //continue to compare the two strings from second character
  132. while( (s_pt < s.length())&&(t_pt < t.length())){
  133. if( s.charAt(s_pt) == t.charAt(t_pt) ){
  134. s_pt++;
  135. t_pt++;
  136. }
  137. else if( s.charAt(s_pt) != t.charAt(t_pt) ){
  138. if(t_pt==0){//The first character
  139. return false;
  140. }
  141. //character at t is duplicated
  142. else if(t.charAt(t_pt) == t.charAt(t_pt-1)){
  143. t_pt++;
  144. }
  145. //not a duplication issue
  146. else{
  147. return false;
  148. }
  149. }
  150. }
  151. //Not all characters in s have a match it t
  152. if(s_pt < s.length()){
  153. return false;
  154. }
  155. //comparison passed
  156. return true;
  157. }//End isTransItr
  158.  
  159.  
  160. //printouts for isTransItr
  161. private static void printOuts(int i, String s, String t, boolean expected, boolean result)
  162. {
  163. System.out.printf("%d)s= [", i);
  164. for (int u = 0; u < s.length(); u++){
  165. System.out.printf("%c ",s.charAt(u));
  166. }
  167. System.out.printf("]\n");
  168. System.out.printf(" %d)t= [", i);
  169. for (int w = 0; w < t.length(); w++){
  170. System.out.printf("%c ",t.charAt(w));
  171. }
  172. System.out.printf("]\n");
  173. if(expected != result){
  174. System.out.printf(" Failed: expected : %b, actual: %b\n\n ",expected,result);
  175. }
  176. else{ //expected == result
  177. System.out.printf(" Passed: expected : %b, actual: %b\n\n ",expected,result);
  178.  
  179. }
  180. }//End printOuts for isTransItr (Tester-3)
  181.  
  182.  
  183. //printouts for tester-2
  184. private static void printDistance(int j, int[] a, int[] bin_array, int[] distances_array,boolean return_value)
  185. {
  186. System.out.printf("%d)a= [", j);
  187. for (int u = 0; u < a.length; u++){
  188. System.out.printf("%d ",a[u]);
  189. }
  190. System.out.printf("]\n");
  191. System.out.printf(" %d)expected distance= [", j);
  192. for (int w = 0; w < distances_array.length; w++){
  193. System.out.printf("%d ",distances_array[w]);
  194. }
  195. System.out.printf("]\n");
  196. System.out.printf(" %d)Actual distance= [", j);
  197. for (int w = 0; w < bin_array.length; w++){
  198. System.out.printf("%d ",bin_array[w]);
  199. }
  200. System.out.printf("]\n");
  201. if( return_value == true){ //expected == result
  202. System.out.printf(" Passed: expected is like actual\n\n ");
  203. }
  204. else if( return_value == false){ //expected != result
  205. System.out.printf(" Failed: expected is different actual\n\n ");
  206. }
  207. }//End printOuts for zeroDistance (Tester-2)
  208.  
  209.  
  210. private static boolean matchWithLoop (int[] a, int[] p)
  211. {
  212. int a_len = a.length;
  213. int p_len = p.length;
  214. boolean found_match = false;
  215.  
  216. //no p --> return true
  217. if(p == null){
  218. return true;
  219. }
  220. //a < p --> return false
  221. else if(a.length < p.length){
  222. return false;
  223. }
  224.  
  225. //Iterate a[] with pattern
  226. for(int i=0; i< a_len - p_len + 1; i++){
  227. if(found_match == true){
  228. return true;
  229. }
  230. else{//set to true for the inner loop
  231. found_match = true;
  232. }
  233. for (int j=0; (j< p_len)&&found_match; j++){
  234. int reminder = a[i+j]/10;
  235. reminder = (reminder < 0) ? -1*reminder : reminder;
  236. if(reminder >= 10){//three digits or more
  237. found_match=false;
  238. }
  239. else if(reminder >= 1){ // two digits
  240. if(p[j]==2 || p[j]==0){
  241. found_match = true;
  242. }
  243. else{ //p[j] == 1
  244. found_match = false;
  245. }
  246. }
  247. else if(reminder < 1){ //single digit
  248. if(p[j]==1 || p[j]==0){
  249. found_match = true;
  250. }
  251. else{//p[j] == 2
  252. found_match = false;
  253. }
  254. }
  255. }
  256. }
  257. return found_match; //for the case that a.len == p.len
  258. }//End Iterative match
  259.  
  260.  
  261. public static boolean TesterForStudents ()
  262. {
  263. int res, n;
  264. boolean result;
  265. int[] a={1,2,3,4};
  266.  
  267. Scanner scan=new Scanner(System.in);
  268. System.out.println("************************** Test what - Started ***************************");
  269. res=Ex14.what(a);
  270. System.out.println(res);
  271. System.out.println("************************** Test what - Finished **************************\n");
  272.  
  273. System.out.println("******************** Test checkZeroDistance - Started ********************");
  274. Ex14.zeroDistance(a);
  275. System.out.println("******************* Test checkZeroDistance - Finished ********************\n");
  276.  
  277. System.out.println("************************ Test isTrans - Started ***********************");
  278. result=Ex14.isTrans("abbcd","aabbccdd");
  279. System.out.println(result); //expected true
  280. if(result != true){
  281. return false;
  282. }
  283. result=Ex14.isTrans("abbcd","abcd");
  284. System.out.println(result); //expected false
  285. if(result != false){
  286. return false;
  287. }
  288. System.out.println("************************ Test isTrans - Finished ***********************\n");
  289.  
  290. System.out.println("***************** Test match - Started ******************");
  291. int[] a1= {2,3,57}, a2= {1,0,2};// expected true
  292. result=Ex14.match(a1, a2);
  293. System.out.println(result);
  294. if(result != true){
  295. return false;
  296. }
  297. int[] b1= {2,3,573,4,324,35} , b2= { }; // expected true
  298. result=Ex14.match(b1, b2);
  299. System.out.println(result);
  300. if(result != true){
  301. return false;
  302. }
  303. int[] c1= {2,3} , c2= {1,0,2}; //expected false
  304. result=Ex14.match(c1, c2);
  305. System.out.println(result);
  306. if(result != false){
  307. return false;
  308. }
  309. System.out.println("****************** Test match - Finished *****************\n");
  310. return true;
  311. }//End Tester-0 (Tester for students)
  312.  
  313.  
  314. public static boolean tester_Q1_manual( boolean printouts_1, int LOOP_TESTER_1){
  315. boolean return_value = false;
  316. int [][]a = {
  317. {-2, 0, 0, 0, 3},
  318. {-16, 63, -43},
  319. {-1, 2, 3},
  320. {-1,0,4},
  321. {-1},
  322. {0,-1,0,-2,-5,-3,-2,-3,-5},
  323. {1, 0, 0, 3, 3, 3, 3},
  324. {2, 0, 5, 3, 3, 3, 3},
  325. {2, 0, 5, 3, 1, 3, 3},
  326. {0, 0, 2, 0, 0, 0, 0},
  327. {1, 0, 1, 0, 0, 1, 2},
  328. {-2, 0, 0, 0, 0, 0, 1},
  329. {-9, -36, 45, 20, 85, -8, -69, -56, 26, -96, -20 }
  330. };
  331. int j=0,k=0;
  332. for(j=0; j<a.length; j++){
  333. return_value = true;
  334. if(printouts_1){
  335. System.out.printf("%3d) [", j);
  336. for(k=0; k<a[j].length-1; k++){
  337. System.out.print( a[j][k]+", ");
  338. }
  339. System.out.printf("%d]\n",a[j][k]);
  340. }
  341. int expected = what_org(a[j]);
  342. int result = Ex14.what(a[j]);
  343. if( expected != result ){
  344. return_value = false;
  345. System.out.printf(" failed: expected-what: %d, actual-what: %d \n",expected, result);
  346. break;
  347. }
  348. else if(printouts_1){
  349. System.out.printf(" Passed: expected-what: %d, actual-what: %d \n",what_org(a[j]), Ex14.what(a[j]));
  350. }
  351. }
  352. return return_value;
  353. }//End tester-1 manual
  354.  
  355.  
  356. public static boolean tester_Q1_Automatic( boolean printouts_1, int LOOP_TESTER_1){
  357. //Tester-1: Start the automatic tests
  358. boolean return_value = false;
  359. int j;
  360. for (j=0; j < LOOP_TESTER_1;j++)
  361. {
  362. return_value = true;
  363. Random rand = new Random();
  364. int[] aa = new int[rand.nextInt(200)];
  365. for (int t = 0; t < aa.length; t++)
  366. {
  367. aa[t] = rand.nextInt(200) - 100;
  368. }
  369. int result = Ex14.what(aa);
  370. int expected = what_org(aa);
  371. if(expected != result){
  372. return_value = false;
  373. System.out.printf("failed: expected-what: %d, actual-what: %d \n",expected,result);
  374. System.out.println();
  375. break;
  376. }
  377. if(printouts_1){
  378. System.out.printf("%3d) [", j);
  379. for (int t = 0; t < aa.length; t++)
  380. {
  381. System.out.printf("%d ",aa[t]);
  382. }
  383. System.out.printf("]");
  384. System.out.printf("\n Passed: expected-what: %d, actual-what: %d\n ",expected,result);
  385. }
  386.  
  387. }
  388. return return_value;
  389. }//End tester_Q1 Automatic
  390.  
  391.  
  392. public static boolean tester_Q2_manual( boolean printouts_2, int LOOP_TESTER_2){
  393. boolean return_value = false;
  394. int [][]aa = {
  395. {0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1 },
  396. {0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0},
  397. {0},
  398. {0, 1},
  399. {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0},
  400. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  401. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  402. {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1},
  403. {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
  404. {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}
  405. };
  406. int j=0,k=0;
  407. for(j=0; j<aa.length; j++){
  408. return_value = true;//default value before test
  409. int[] a = new int[aa[j].length];
  410. //save the original binary - array
  411. for(k=0; k<aa[j].length; k++){
  412. a[k] = aa[j][k];
  413. }
  414. Ex14.zeroDistance(a);
  415. int[] distances_array = zeroDistanceItr(aa[j]);
  416. //Both arrays should have the same length
  417. if(distances_array.length != a.length){
  418. return_value = false;
  419. printDistance(j, a, aa[j], distances_array, return_value);
  420. }
  421. //compare the binarry arrays: expected_array and bin_array (modified by zeroDistance)
  422. for( k=0; k<a.length; k++){
  423. if (a[k] != distances_array[k]){
  424. return_value = false;
  425. printDistance( j,a, aa[j], distances_array, return_value);
  426. return return_value;
  427. }
  428. }
  429. //If need to print arrays
  430. if(printouts_2){
  431. printDistance(j, a, aa[j], distances_array, return_value);
  432. }
  433. }
  434. return return_value;
  435. }//End tester-2 manual
  436.  
  437.  
  438. public static boolean tester_Q2_Automatic( boolean printouts_2, int LOOP_TESTER_2){
  439. boolean return_value = false;
  440. int j;
  441. for (j=0; j < LOOP_TESTER_2;j++)
  442. {
  443. return_value = true;
  444. Random rand = new Random();
  445. int[] bin_array = new int[rand.nextInt(100)]; //A binarry 0 to 100 in length
  446. int[] a = new int[bin_array.length];
  447. int count_ones=0;
  448. for (int t = 0; t < bin_array.length; t++)
  449. {
  450. bin_array[t] = rand.nextInt(2); //set 0 or 1
  451. a[t] = bin_array[t]; //save the original binary - array
  452. if(a[t]==1){
  453. count_ones++;
  454. }
  455. }
  456. //check that '0' exists:
  457. if( (count_ones == bin_array.length)||(bin_array.length==0) ){ //all bin_array elements are '1'
  458. //loop again with the same j value
  459. j--;
  460. continue;
  461. }
  462.  
  463. if( (count_ones == bin_array.length)||(bin_array.length==0)){ //all bin_array elements are '1'
  464. //loop again with the same j value
  465. printDistance(j,a, bin_array, bin_array, false);
  466. return false;
  467. }
  468.  
  469. Ex14.zeroDistance(bin_array);
  470. int[] distances_array = zeroDistanceItr(bin_array);
  471. //Both arrays should have the same length
  472. if(distances_array.length != bin_array.length){
  473. return_value = false;
  474. printDistance(j,a, bin_array, distances_array, return_value);
  475. }
  476. //compare the binarry arrays: expected_array and bin_array (modified by zeroDistance)
  477. for( int k=0; k<bin_array.length; k++){
  478. if (bin_array[k] != distances_array[k]){
  479. return_value = false;
  480. printDistance( j,a, bin_array, distances_array, return_value);
  481. return return_value;
  482. }
  483. }
  484. //If need to print arrays
  485. if(printouts_2){
  486. printDistance(j, a, bin_array, distances_array, return_value);
  487. }
  488. }
  489. return return_value;
  490. }//End tester_Q2 Automatic
  491.  
  492.  
  493. public static boolean tester_Q3(boolean printouts, int LOOP_TESTER_3){
  494.  
  495. int i;
  496. boolean return_value = false;
  497. for (i = 0; i < LOOP_TESTER_3; i++)
  498. {
  499. return_value = true; //set The tests result to be true, before testing
  500. Random r = new Random();
  501. String alphabet = "abcdefghijklmnopqrstuvwxyz";
  502. Random rand = new Random();
  503. char[] s_char = new char[rand.nextInt(15)];//define a[] length up to 15 characters
  504. char[] t1_char = new char[s_char.length];
  505. char[] t2_char = new char[11*s_char.length];
  506. char[] t3_char = new char[11*s_char.length];
  507. int indx_t2 = 0;
  508. int indx_t3 = 0;
  509. for( int j=0; j<s_char.length; j++){
  510. s_char[j] = alphabet.charAt(r.nextInt(alphabet.length()));
  511. t1_char[j] = s_char[j]; //t1 is a simple duplication of s
  512. int duplicate = rand.nextInt(10)+1;//define a duplication factor from 1 to 11;
  513. //duplicating t2
  514. for( int k=0; k< duplicate; k++){
  515. t2_char[indx_t2] = s_char[j]; //duplicate s[] characters, in order
  516. indx_t2++;
  517. }
  518. duplicate = rand.nextInt(10);//define a duplication factor from 0 to 10;
  519. //duplicating t3
  520. for( int k=0; k< duplicate; k++){
  521. t3_char[indx_t3] = s_char[j]; //duplicate s[] characters, in order
  522. indx_t3++;
  523. }
  524. }
  525. //create string s: copy s_char[] into s
  526. String s = new String(s_char);
  527. //Create t1[]: a simple duplication of s --> a transformation
  528. String t1 = new String(t1_char);
  529. //create t2[]: s with inner duplications --> a transformation
  530. char []t2_char_upd = new char[indx_t2];
  531. for(int k=0; k< indx_t2; k++){
  532. t2_char_upd[k] = t2_char[k];
  533. }
  534. String t2 = new String(t2_char_upd);
  535.  
  536. //Create t3: based on t1, only may extends the inner character or leave it empty
  537. char []t3_char_upd = new char[indx_t3];
  538. for(int k=0; k< indx_t3; k++){
  539. t3_char_upd[k] = t3_char[k];
  540. }
  541. String t3 = new String(t3_char_upd);
  542.  
  543. boolean result = Ex14.isTrans(s,t1);
  544. boolean expected = isTransItr(s,t1);
  545. boolean result_2 = Ex14.isTrans(s,t2);
  546. boolean expected_2 = isTransItr(s,t2);
  547. boolean result_3 = Ex14.isTrans(s,t3);
  548. boolean expected_3 = isTransItr(s,t3);
  549. //print strings
  550. if(printouts){
  551. printOuts(3*i+1,s,t1,expected, result);
  552. printOuts(3*i+2,s,t2, expected_2, result_2);
  553. printOuts(3*i+3,s,t3, expected_3, result_3);
  554. }
  555. //check expected-result
  556. if(expected != result){
  557. return_value = false; //found a failed test
  558. printOuts(3*i+1,s,t1, expected, result);
  559. System.out.println();
  560. break;
  561. }
  562. //check expected-result (2)
  563. else if(expected_2 != result_2){
  564. return_value = false; //found a failed test
  565. printOuts(3*i+2,s,t2, expected_2, result_2);
  566. System.out.println();
  567. break;
  568. }
  569. //check expected-result (3)
  570. else if(expected_3 != result_3){
  571. return_value = false; //found a failed test
  572. printOuts(3*i+3,s,t3, expected_3, result_3);
  573. System.out.println();
  574. break;
  575. }
  576. }
  577. return return_value;
  578. }//End tester_Q3
  579.  
  580.  
  581. public static boolean tester_Q4(boolean printouts, int LOOP_TESTER_4)
  582. {
  583. int i;
  584. boolean return_value = false;
  585. for (i = 0;i< LOOP_TESTER_4;i++)
  586. {
  587. return_value=true;//default value
  588. Random rand = new Random();
  589. int[] a = new int[rand.nextInt(15)];//define a[] length up to 200 elements
  590. int[] p = new int[rand.nextInt(5)];//define p[] length up to 20 elements
  591. for (int t = 0; t < a.length; t++)
  592. {
  593. a[t] = rand.nextInt(120); //set random numbers for a[]: -100 to 120
  594. }
  595. for(int s = 0; s < p.length; s++)
  596. {
  597. p[s] = rand.nextInt(3); //set random values: 0,1,2
  598. }
  599. boolean result = Ex14.match(a,p);
  600. boolean expected = matchWithLoop(a,p);
  601. if(printouts){
  602. System.out.printf("%d) [", i);
  603. for (int t = 0; t < a.length; t++)
  604. {
  605. System.out.printf("%d ",a[t]);
  606. }
  607. System.out.printf("]\n");
  608. System.out.printf(" %d) [", i);
  609. for (int s = 0; s < p.length; s++)
  610. {
  611. System.out.printf("%d ",p[s]);
  612. }
  613. System.out.printf("]\n");
  614. System.out.printf(" Passed: expected: %b, actual: %b\n\n ",expected,result);
  615.  
  616.  
  617.  
  618. }
  619. if(expected != result){
  620. return_value = false;
  621. System.out.println("failed: expected: "+ expected + " Actual: "+ result );
  622. System.out.println();
  623. break;
  624. }
  625. }
  626. return return_value;
  627. }
  628.  
  629.  
  630. public static void main( String args[] ){
  631. /* No change below this line ! */
  632. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  633. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  634. /* No change below this line ! */
  635.  
  636. boolean testerresult_0=false; // don't change !
  637. boolean testerresult_1_man=false; // don't change !
  638. boolean testerresult_1_Auto=false; // don't change !
  639. boolean testerresult_2_man=false; // don't change
  640. boolean testerresult_2_Auto=false; // don't change
  641. boolean testerresult_3=false; // don't change !
  642. boolean testerresult_4=false; // don't change !
  643.  
  644. if(TESTER_0)
  645. {
  646. System.out.printf("\n\n\ntester-0\n");
  647. testerresult_0 = TesterForStudents();
  648. }
  649. if(TESTER_1)
  650. {
  651. if(printouts_1 == true){
  652. System.out.printf("\n\n\ntester-1 manual\n");
  653. }
  654. testerresult_1_man = tester_Q1_manual(printouts_1,LOOP_TESTER_1);
  655. if(printouts_1 == true){
  656. System.out.printf("\n\n\ntester-1 Automatic\n");
  657. }
  658. testerresult_1_Auto = tester_Q1_Automatic(printouts_1,LOOP_TESTER_1);
  659. }
  660. if(TESTER_2)
  661. {
  662. if(printouts_2 == true){
  663. System.out.printf("\n\n\ntester-2 \n");
  664. }
  665. testerresult_2_man = tester_Q2_manual(printouts_2,LOOP_TESTER_2);
  666. if(printouts_2 == true){
  667. System.out.printf("\n\n\ntester-2 Automatic\n");
  668. }
  669. testerresult_2_Auto = tester_Q2_Automatic(printouts_2,LOOP_TESTER_2);
  670. }
  671. if(TESTER_3)
  672. {
  673. if(printouts_3 == true){
  674. System.out.printf("\n\n\ntester-3 \n");
  675. }
  676. testerresult_3 = tester_Q3(printouts_3,LOOP_TESTER_3);
  677. }
  678. if(TESTER_4)
  679. {
  680. if(printouts_4 == true){
  681. System.out.printf("\n\n\ntester-4 \n");
  682. }
  683. testerresult_4 = tester_Q4(printouts_4,LOOP_TESTER_4);
  684. }
  685.  
  686. //Results
  687. System.out.printf("\n\n\n");
  688. if(TESTER_0)
  689. {
  690. if( testerresult_0 == true ){
  691. System.out.printf("Students-Tester: ON, Passed \n");
  692. }
  693. else if( testerresult_0 == false ){
  694. System.out.printf("Students-Tester: ON, Failed \n");
  695. }
  696. }
  697. else if(TESTER_0 == false){
  698. System.out.printf("Students-Tester: OFF\n");
  699. }
  700.  
  701. if(TESTER_1)
  702. {
  703. if( printouts_1 ){
  704. System.out.printf("Tester-1: printouts ON, ");
  705. }
  706. else if( !printouts_1 ){
  707. System.out.printf("Tester-1: printouts OFF, ");
  708. }
  709. if( testerresult_1_man == true ){
  710. System.out.printf("Tester-1: ON, Manual arrays passed \n");
  711. }
  712. else if(testerresult_1_man == false){
  713. System.out.printf("Tester-1: ON, Manual arrays Failed\n");
  714. }
  715. if( printouts_1 ){
  716. System.out.printf("Tester-1: printouts ON, ");
  717. }
  718. else if( !printouts_1 ){
  719. System.out.printf("Tester-1: printouts OFF, ");
  720. }
  721. if( testerresult_1_Auto == true ){
  722. System.out.printf("Tester-1: ON, Automatic arrays passed \n");
  723. }
  724. else if(testerresult_1_Auto == false){
  725. System.out.printf("Tester-1: ON, Automatic arrays Failed\n");
  726. }
  727. }
  728. else if(TESTER_1 == false){
  729. System.out.printf("Tester-1: OFF\n");
  730. }
  731.  
  732. if(TESTER_2)
  733. {
  734. if( printouts_2 ){
  735. System.out.printf("Tester-2: printouts ON, ");
  736. }
  737. else if( !printouts_2 ){
  738. System.out.printf("Tester-2: printouts OFF, ");
  739. }
  740. if( testerresult_2_man == true ){
  741. System.out.printf("Tester-2: ON, manual arrays passed \n");
  742. }
  743. else if(testerresult_2_man == false){
  744. System.out.printf("Tester-2: ON, manual arrays Failed\n");
  745. }
  746. if( printouts_2 ){
  747. System.out.printf("Tester-2: printouts ON, ");
  748. }
  749. else if( !printouts_2 ){
  750. System.out.printf("Tester-2: printouts OFF, ");
  751. }
  752. if( testerresult_2_Auto == true ){
  753. System.out.printf("Tester-2: ON, Automatic arrays passed \n");
  754. }
  755. else if(testerresult_2_Auto == false){
  756. System.out.printf("Tester-2: ON, Automatic arrays Failed\n");
  757. }
  758. }
  759. else if(TESTER_2 == false){
  760. System.out.printf("Tester-2 OFF\n");
  761. }
  762.  
  763. if(TESTER_3)
  764. {
  765. if( printouts_3 ){
  766. System.out.printf("Tester-3: printouts ON, ");
  767. }
  768. else if( !printouts_3 ){
  769. System.out.printf("Tester-3: printouts OFF, ");
  770. }
  771. if( testerresult_3 == true ){
  772. System.out.printf("Tester-3: ON, Automatic strings passed \n");
  773. }
  774. else if(testerresult_3 == false){
  775. System.out.printf("Tester-3: ON, Automatic strings Failed\n");
  776. }
  777. }
  778. else if(TESTER_3 == false){
  779. System.out.printf("Tester-3 OFF\n");
  780. }
  781.  
  782. if(TESTER_4)
  783. {
  784. if( printouts_4 ){
  785. System.out.printf("Tester-4: printouts ON, ");
  786. }
  787. else if( !printouts_4 ){
  788. System.out.printf("Tester-4: printouts OFF, ");
  789. }
  790. if( testerresult_4 == true ){
  791. System.out.printf("Tester-4: ON, Automatic arrays passed \n");
  792. }
  793. else if(testerresult_4 == false){
  794. System.out.printf("Tester-4: ON, Automatic arrays Failed match\n");
  795. }
  796. }
  797. else if(TESTER_4 == false){
  798. System.out.printf("Tester-4 OFF\n");
  799. }
  800. }
  801. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement