Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Change the width of the box to 30 and change the height of the box to 50 by using the following method. setSize(int width,

1. Change the width of the box to 30 and change the height of the box to 50 by using the following method.

setSize(int width, int height)

2. Remove the translate method from the code.

3. Get and print the new width and height of the rectangle. Hint*: Use the getWidth() and getHeight()methods.

4. Also print the expected answer.

import java.awt.Rectangle;

public class MoveTester { public static void main(String[] args) { Rectangle box = new Rectangle(5, 10, 20, 30);

// Move the rectangle box.translate(15, 25);

// Print information about the moved rectangle System.out.print("x: "); System.out.println(box.getX()); System.out.println("Expected: 20");

System.out.print("y: "); System.out.println(box.getY()); System.out.println("Expected: 35"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions