I can't figure out the answer to this homework problem:
Write a static method named countEmptyBowls, to be added to the Bowl class, which is passed an array of Bowl objects, and returns the (int) number of Bowl objects in the array that are empty.
Bowl Class:
public class Bowl { private double weight; private boolean empty; private String origin; // country of manufacture public Bowl(double w, boolean e, String origin) { weight = w; empty = e; this.origin = origin; } public double getWeight() { return weight; } public boolean getEmpty() { return empty; } public String getOrigin() { return origin; } public void setEmpty(boolean emptyStatus) { empty = emptyStatus; } public String toString() { return ("from " + origin + " weight: " + weight); } }
This is my most recent try for the method:
public int countEmptyBowls(int[] Bowl){ int count = 0; for(k = 0;k<Bowl.length;k++){ if(k.getEmpty()== true) count++; return count;}
This didn't work. Ive tried a few other things but they didn't work either :'(
Thanks for helping!