I have this class
public class Room{
private int n_bed;
private float cost;
private Collection<Client> clientlist;
public Room(int n,float c){
n_bed = n;
cost = c;
clientlist = new ArrayList<Client>();
}
}
and this class inherited from the above class
public class RoomWithBar extends Room{
private Collection<Drink> drinkslist;
public RoomWithBar(int n,float cost){
super(n,cost);
drinkslist = new ArrayList<Drink>();
}
public Collection<Drink> getDrinksList(){
return drinkslist;
}
public void addDrink(Drink drink){
drinkslist.add(drink)
}
}
my question is: I have to insert also the collection clientlist in the class RoomWithBar or the collection automatically is inherited?
Thats what
protectedmodifier does.Now,
clientlistwill be accessible in derived classes.For details click here.