Skip to content Skip to sidebar Skip to footer

Restaurant Program Tutorial

I was continuing work on my Android tutorial that my teacher gave to me. The idea of the program is to enter in a restaurant name, address and type of restaurant and create an inte

Solution 1:

Add this to your Restaurant class

publicStringgetType() {
    returntype;
}

Solution 2:

In answer to the first part of your quest, based on the code you've given us, you definitely need to implement the getType() method in the Restaurant class.

With respect to the NullPointerException, that will likely be because your getType implementation returns the value for type which may not be initialised (and indeed, can't be set given that your setType implementation has no logic). You will need to do something like:

publicvoidsetType(Stringstring) {
    this.type = string;
}

You may also want to do some null checking of the returned type value in your LunchList usage of getType. Depends on how you use it.

Post a Comment for "Restaurant Program Tutorial"