Joe Parks
Posts: 107
Nickname: joeparks
Registered: Aug, 2003
|
|
Re: can anyone help me with this assignment?
|
Posted: Sep 8, 2003 2:09 PM
|
|
Here's a start. You'll have to put in your own parsing logic (as that, apparently, is your homework), but this will at least compile.
public class NumberReader {
public static void main(String [] args) {
NumberReader numberReader = new NumberReader();
numberReader.setInt(5120);
System.out.println("Number of zeroes: " + numberReader.getZeroCount());
System.out.println("Number of odds: " + numberReader.getOddCount());
System.out.println("Number of evens: " + numberReader.getEvenCount());
}
private String sInt;
private int zeroCount;
private int oddCount;
private int evenCount;
public void setInt(int theInt) {
this.sInt = Integer.toString(theInt);
parse();
}
private void parse() {
// TODO
}
public int getZeroCount() {
return zeroCount;
}
public int getOddCount() {
return oddCount;
}
public int getEvenCount() {
return evenCount;
}
}
|
|