provide the definition of an abstract class named DesktopComponent that contains the following:-a void (abstract) method, onClicked, that accepts no parameters and is to be supplied by a subclass.-a (private) string named type, describing the sort of Desktop component (e.g. window, icon, taskbar, etc).-a constructor accepting a string that is used to initialize the type instance variable

LANGUAGE: JAVA

CHALLENGE:

provide the definition of an abstract class named DesktopComponent that contains the following:-a void (abstract) method, onClicked, that accepts no parameters and is to be supplied by a subclass.-a (private) string named type, describing the sort of Desktop component (e.g. window, icon, taskbar, etc).-a constructor accepting a string that is used to initialize the type instance variable

SOLUTION:

public abstract class Window {
   private int width;
   private int height;
   public int getWidth(){
      return width;
   }

   public int getHeight(){
      return height;
   }

   public Window (int theWidth, int theHeight){
      width = theWidth;
      height = theHeight;
   }

   public abstract void paint();
}

Posted in ,