jdalbey

Double Maintenance Defect Example

Feb 6th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.47 KB | None | 0 0
  1. /** Find the defect in this code, caused by the "double maintenance" problem */
  2.  
  3. // "right-click" is simulated by prefix period character
  4. boolean rightclick = false;
  5. if (line.charAt(0) == '.')
  6. {
  7.     rightclick = true;
  8.     line = line.trim().substring(1,3);
  9. }
  10. // parse the move
  11. char letter = Character.toUpperCase(line.trim().charAt(0));
  12. int row = letter - 'A';
  13. String column = line.trim().substring(1, line.length());
  14. int col = Integer.parseInt(column) - 1;  // zero-base
Advertisement
Add Comment
Please, Sign In to add comment