Building a tester class?

I am a very new java user, and I have always had trouble with testing my programs. Here I have implement a basic boolean array interface. I want to test it buy adding a couple values and then running each of the interface methods. Please be nice I am not very good at this but I want to get better. package booleanmatrix; import java.util.Arrays; /** * * @author David */ public class ArrayMatrix implements BooleanMatrixs { private boolean a[][]; public int Rows; public int Cols; public int capacityr = 1; public int capacityc = 1; public int pT=0; public int pF=0; public ArrayMatrix() { a = new boolean[capacityr][capacityc]; } @Override public int getNumberRows() { return capacityr; } @Override public int getNumberCols() { return capacityc; } @Override public void set(int row, int col) throws IndexOutOfBoundsException { if (row > capacityr) { capacityr = row; boolean B[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { B[k][j] = a[k][j]; } } a = B; } if (col > capacityc) { capacityc = col; boolean C[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { C[k][j] = a[k][j]; } } a = C; } a[row][col] = true; pT++; } @Override public void clear(int row, int col) throws IndexOutOfBoundsException { if (row > capacityr) { capacityr = row; boolean B[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { B[k][j] = a[k][j]; } } a = B; } if (col > capacityc) { capacityc = col; boolean C[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { C[k][j] = a[k][j]; } } a = C; } a[row][col] = false; } @Override public void set(int row, int col, boolean value) throws IndexOutOfBoundsException { if (row > capacityr) { capacityr = row; boolean B[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { B[k][j] = a[k][j]; } } a = B; } if (col > capacityc) { capacityc = col; boolean C[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { C[k][j] = a[k][j]; } } a = C; } a[row][col] = value; if(value==true){ pT++; } } @Override public void toggle(int row, int col) throws IndexOutOfBoundsException { if (row > capacityr) { capacityr = row; boolean B[][] = new boolean[capacityr][capacityc]; for (int k = 0; k < capacityr; k++) { for (int j = 0; j < capacityc; j++) { B[k][j] = a[k][j]; } } a = B; } if (col > capacityc) { capacityc = col; boolean C[][] = new boolean[capacityr][capacityc]; for (int k = 0; k

以上就是Building a tester class?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏