Create a Model Class
Now, we want to add a class to the project that will hold onto individual restaurants that will appear in the LunchList. Right now, we can only really work with one restaurant, but that will change in a future tutorial.
So, using your text editor, create a new file named LunchList/src/apt/tutorial/Restaurant.java with the following contents:
package apt.tutorial;
public class Restaurant {
private String name="";
private String address="";
public String getName() {
return(name);
}
public void setName(String name) {
this.name=name;
}
public String getAddress() {
return(address);
}
public void setAddress(String address) {
this.address=address;
}
}
This is simply a rudimentary model, with private data members for the name and address, and getters and setters for each of those. Of course, don't forget to save your changes!
So, using your text editor, create a new file named LunchList/src/apt/tutorial/Restaurant.java with the following contents:
package apt.tutorial;
public class Restaurant {
private String name="";
private String address="";
public String getName() {
return(name);
}
public void setName(String name) {
this.name=name;
}
public String getAddress() {
return(address);
}
public void setAddress(String address) {
this.address=address;
}
}
This is simply a rudimentary model, with private data members for the name and address, and getters and setters for each of those. Of course, don't forget to save your changes!
No comments:
Post a Comment