rebeccakjoyce
2009-04-02 09:43:00 UTC
The code below shows some of the text for a class called City. Now write a complete public constructor, which takes a String parameter called cityName. Your code should initialize the name attribute of the City class to the value of cityName. It should initialize the population attribute to a value of -1.
This is my answer:
public class City {
private String name;
private int population;
public City(int p, String n){
population = p;
name = n;
}
public City(){
population = -1;
name = "cityName";
}
public String cityName(){
return name;
}
}
This is my error:
City() is already defined in constructors.City
Any ideas what I should do?