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

5
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();
}

5 comments

  • Emi says:

    This is a completely different problem you’ve answered.

  • john says:

    can you please answer the problem?

  • KenM66 says:

    This is the answer to problem associated with this number…

    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();

    }

  • jps123 says:

    This is the correct Answer

    public abstract class DesktopComponent {

    // Instance variable type
    private String type;

    // Constructor:
    public DesktopComponent(String type) {
    this.type = type;
    }

    // Abstract method onClicked
    public abstract void onClicked();

    }

  • j p says:

    This is the correct code:

    public abstract class Window {

    private int width;
    private int height;
    public int getWidth() {
    return width;
    }
    public int getHeight() {
    return height;
    }
    public Window(int w, int h) {
    width = w;
    height = h;
    }
    public abstract void paint();
    }

Add comment