0

In the class Album I have an ArrayList of visuals where I add a new Visual. Visual class is a parent class and it has also a child class Movie. Each of this classes has a method play(). When I call method play() in the method addVisual() in the class Album , it calls the method of child class(overriding). But I want to call the play() method of parent class. How can I do it?

    // class Album
    public boolean addVisual(Visual newPhoto)
    {
    for(Visual h: visuals)
    {
        if(h.play().equals(newPhoto.play()))
        {
            return false;
        }
    }

    visuals.add(newPhoto);
    return true;
}
Jack M
  • 1
  • 2
  • create instance of parent class then ? or use `super` ? – Ravi Sep 27 '17 at 17:20
  • In general you use [`super`](https://docs.oracle.com/javase/tutorial/java/IandI/super.html) to invoke method of a parent class. – PM 77-1 Sep 27 '17 at 17:21

0 Answers0