Write a program in which :A class Player have there methods play(),pause(),stop(). And create two another classes Generic Player that extends class Player. The play,pause and stop method of the generic Player can play,pause and stop respectively. The play,pause and stop method of the Dvd Player can play,pause and stop respectively. Make a class Player and call all methods of Generic Player and Dvd Player through the object reference of Player.

class Player
 {
   void play()
   {
    System.out.println("Start the game");
   }
   void pause()
   {
    System.out.println("stop the game for rest 5 min.");
   }
   void stop()
   {
    System.out.println("finish the game");
   }
 }
class GenericPlayer extends Player
  {
    void play()
   {
    System.out.println("Start the game for GenericPlayer");
   }
    void pause()
   {
    System.out.println("resume the game for GenericPlayer");
   }
    void stop()
   {
    System.out.println("end the game for GenericPlayer");
   }
}
class DvdPlayer extends GenericPlayer
  {
    void play()
   {
    System.out.println("Start the game for dvdPlayer");
   }
    void pause()
   {
    System.out.println("resume the game for dvdPlayer");
   }
    void stop()
   {
    System.out.println("end the game for dvdPlayer");
   }
   public static void main(String args[])
    {
     DvdPlayer ab=new DvdPlayer();
     ab.play();
     ab.pause();
     ab.stop();
    }
    
}

No comments:

Post a Comment