Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DigitStorage {
- private int[] count = new int[10];
- //answer q3.1 - implement a constructor
- public DigitStorage(int num) {
- while(num>0) {
- int digit = num%10;
- num /= 10;
- count[digit]++;
- } //end of while loop
- }
- //answer q3.2
- public boolean isSame(DigitStorage other) {
- for (int i = 0; i < count.length; i++) {
- if(count[i] != other.getCount()[i])
- return false;
- }
- return true;
- }
- public int[] getCount() {
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement