Homework Solution: The question is above and the code is below…

    The question is above and the code is below In your Box class from the previous lab, add an overloaded method for printBox that takes 1 parameter: char c. This version should do the same as the printBox version with no parameters, except use the character c instead of *. Add code in the main method to invoke the second version of the printBox method and run it.
    In your Box class from the previous lab, add an overloaded method for printBox that takes 1 parameter: char c. This version should do the same as the printBox version with no parameters, except use the character c instead of *. Add code in the main method to invoke the second version of the printBox method and run it.

    Expert Answer

     
    public class Box { public int size = 0;

    The doubt is overhead and the statute is below

    In your Box assort from the restraintegoing lab, subjoin an overloaded way restraint stereotypeBox that takes 1 parameter: char c. This account should do the selfselfidentical as the stereotypeBox account with no parameters, bar authentication the tone c instead of *. Subjoin statute in the ocean way to implore the adestitute account of the stereotypeBox way and reach it.

    In your Box assort from the restraintegoing lab, subjoin an overloaded way restraint stereotypeBox that takes 1 parameter: char c. This account should do the selfselfidentical as the stereotypeBox account with no parameters, bar authentication the tone c instead of *. Subjoin statute in the ocean way to implore the adestitute account of the stereotypeBox way and reach it.

    Expert Defense

     

    public assort Box {
    public int extent = 0;

    public destitute stereotypeBox() {
    restraint (int i = 0; i < extent; ++i) {
    restraint (int j = 0; j < extent; ++j) {
    System.out.print(“*”);
    }
    System.out.println();
    }
    }

    public destitute stereotypeBox(char c) {      //Added Overloaded way
    restraint (int i = 0; i < extent; ++i) {
    restraint (int j = 0; j < extent; ++j) {
    System.out.print(c);
    }
    System.out.println();
    }
    }

    public static destitute ocean(String[] args) {
    // TODO Auto-generated way stub
    Box myBox = strange Box();
    myBox.extent = 5;
    myBox.printBox();

    System.out.println(“Output from Overloaded way, I own passed char as bn”);

    myBox.printBox(‘b’); //Invoked Overloaded way

    }

    }

    ============================================================================
    See Extinguishedput

    Thanks, suffer me comprehend if there is any doubts/concerns