Ask Question
23 January, 08:57

Assume the existence of a Window class with a constructor that accepts two integer parameters containing the width and height of the window (in that order). Assume a subclass TitledWindow has been defined that has two instance variables: a string named text for the text of the title and, an integer, titleBarHeight for the height of the title bar. Write a constructor for TitledWindow that accepts four parameters: two integers containing the width and height (which are passed up to the Window constructor), and, a string and integer which are used to initialize the TitledWindow instance variables. The height of the title bar should be 'clamped' by the constructor to one half the height of the window- - i. e., if the height of the title bar passed into the constructor is greater than one half the specified height of the window, it should be set to one half the height of the window.

+3
Answers (1)
  1. 23 January, 12:56
    0
    The answer to the following question:

    TitledWindow (int titleBarHeight, int height, int width, String text) / /define subclass and pass an argument of four variable

    {

    //define constructor and pass an argument of two variable

    super (height, width);

    this. text = text;

    //set if condition

    if (titleBarHeight > height / 2)

    titleBarHeight = height / 2;

    this. titleBarHeight = titleBarHeight;

    }

    Explanation:

    Here, we have define a subclass of the "Window" class i. e., "TitledWindow" and pass four variable in the argument.

    Then, define constructor and pass two variable in the argument.

    Then, set if condition and pass the condition "titleBarHeight > height / 2".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume the existence of a Window class with a constructor that accepts two integer parameters containing the width and height of the window ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers