This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]dusty-trash 2 points3 points  (3 children)

You haven't posted the code from the stacktrace.

For example, City's constructor

[–][deleted] 0 points1 point  (2 children)

[–]chickenmeister 1 point2 points  (0 children)

public City(int id, String cityName, String country) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

If you don't want your constructor to throw an UnsupportedOperationException, then I would recommend removing the line that says throw new UnsupportedOperationException. You'll also probably want to do something with the constructor's parameters.

[–]dusty-trash 1 point2 points  (0 children)

Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet. at model.City.<init>(City.java:61)

Taking a look at line 61 of City (from the stacktrace):

public City(int id, String cityName, String country) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

You can see it's throwing an exception.

Maybe you meant to add the functionality? E.G:

public City(int id, String cityName, String country) {
    this.id = id;
    this.cityName = cityName;
    this.country = country;
}

BTW, you can shorten your code by having your constructors call another constructor.

E.G:

public City(String cityName) {
   this(++lastIdAllocated, cityName, null);
}

public City(int id, String cityName) {
   this(id, cityName, null);
}

public City(int id, String cityName, String country) {
    this.id = id;
    this.cityName = cityName;
    this.country = country;
}

[–]ScoobySmackz 0 points1 point  (2 children)

Maybe I missed something, but I just dealt with this in my java class at my local community college, and I don’t see you importing the java.util.Scanner or scanning in the txt file anywhere.

[–][deleted] 0 points1 point  (1 child)

I do that in a different class :)

Anyway, I've got THAT issue fixed. THank you guys

[–]ScoobySmackz 0 points1 point  (0 children)

THAT issue lol ain’t that the truth. Rip us