Explore BrainMass
Share

Explore BrainMass

    Read and Understand Code

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Read and Understand Code
    What is the length of the line being drawn?
    g.drawLine (50, 20, 50, 350);
    What is the (x, y) coordinate of the lower-right corner of the rectangle being drawn?
    g.drawRect (10, 20, 250, 350);
    _______________________________________________________________________________
    Fill in the code
    This code sets the current color to red
    // assume you have a Graphics object named g
    // code goes here
    This code draws the string "Fill in the Code" with the lower-left corner of the first character (the f) being coordinate (100, 250).
    // assume you have a graphics object called g
    // code goes here
    Identifying Errors in Code
    Where is the error in this code sequence?
    // we are inside method paint
    g.drawString ('find the bug', 100, 200);
    Where is the error in this code sequence?
    // we are inside method paint
    g.setColor(green);

    © BrainMass Inc. brainmass.com October 10, 2019, 6:32 am ad1c9bdddf
    https://brainmass.com/computer-science/programming-languages/read-understand-code-547930

    Solution Preview

    What is the length of the line being drawn?
    g.drawLine (50, 20, 50, 350);
    ans: length=sqrt[(50-50)^2+(350-20)^2]=330

    What is the (x, y) coordinate of the lower-right corner of the rectangle being drawn?
    g.drawRect (10, 20, 250, 350);
    ans: (x, y) coordinate = (10+250, 20-350) = (260, ...

    Solution Summary

    The solution gives detailed guide to some coding questions. I provide both answers and explanations.

    $2.19