//I am supposed to make an abacusmodel and test it if it works or not. Now i've made this code,
//but something is not right, the test dosent say whats wrong, so that dosent help.
//Could anyone check the code and see if something obvious is missing?
//workshop 3, until task 4 is what i've done. i now this is a homework but some help would ease my mind,
//because this anoys me. thanks
//but something is not right, the test dosent say whats wrong, so that dosent help.
//Could anyone check the code and see if something obvious is missing?
//workshop 3, until task 4 is what i've done. i now this is a homework but some help would ease my mind,
//because this anoys me. thanks
class AbacusModel { int num_of_pegs; int max_num_counters; int peg_array[]; public AbacusModel(int num_pegs, int num_counters) { max_num_counters = num_counters; num_of_pegs = num_pegs; peg_array = new int[num_of_pegs]; } boolean addCounter(int thisPeg) { if(thisPeg < 0 || thisPeg >= num_of_pegs) { System.out.println(2); return false; } else if(thisPeg > max_num_counters) { System.out.println(3); return false; } else { System.out.println(4); peg_array[thisPeg]++; return true; } } boolean removeCounter (int thisPeg) { if(thisPeg < 0 || thisPeg >= num_of_pegs || num_of_pegs < 1 ) { System.out.println(5); return false; } else { System.out.println(6); peg_array[thisPeg]--; return true; } } int getNumCounters(int thisPeg) { if( thisPeg < 0 || thisPeg > peg_array[thisPeg]) { System.out.println(7); return 12; } else { System.out.println(8); return thisPeg; } } public static void main(String[] args) { AbacusModel myAbacus = new AbacusModel(7, 5); } }