SYSC 2004 Lecture Notes - Lecture 3: Semi-Major And Semi-Minor Axes, Ellipse
Document Summary
The state of a pen object named pen1 is: xposition : 40; yposition : 20; direction : 2; down : true; colour : // this refers to the current object this. xposition = newx; this. yposition = newy; } xposition and yposition changes. Write a method called setwidth() that changes the width of the line that a pen will draw. The method has one parameter, which is the new line width. /** position of the pen along the x-axis. private int xposition; /** position of the pen along the y-axis. private int yposition; /** the direction in which the pen will move. private int direction; /** true means that the pen is down on the canvas and will draw when it is moved. private boolean down; /** the width of the line drawn by the pen. private int width public void setwidth(int width) { if (width >= 0) { this. width = width; }}