//an example of an interface //also shows how the interface could be "implemented" in a class. import java.util.*; public interface Inhabitable { public int MAXRESIDENTS = 20; ////////////////////////////////////////////// //This method should return a Resident array public Resident[] getResidents(); //////////////////////////////////////////////// //this method shoudl take in a Resident and add it to the instance public void addResident(Resident r); } class Resident { //just a basic class to represent a Resident protected String name; public Resident(){ //default constructor this("no name"); } public Resident (String name){ this.name = name; } } class Metropolis extends City implements Inhabitable { //A type of City private ArrayList residents; public Metropolis(){ //default constructor, creates the arrayList object //(remember this will have called the City Default constructor) //Assume City has a defined default constructor (add this to your City to test) residents = new ArrayList(); } public Resident[] getResidents(){ //returns an array of the residents return this.residents.toArray(new Resident[this.residents.size()]); } public void addResident(Resident r){ //adds a resident to the list residents.add(r); } }