'Removing Variables
my work says to Remove the r, c and e variables from this how would I do this
Rectangle r = new Rectangle(10 * iFrame, 10 * iFrame, 50, 50); r.draw(gcw);
Circle c= new Circle(200, 300 - iFrame*5, 100); c.draw(gcw);
Ellipse e = new Ellipse(150, 300, 90 + iFrame, 160); e.draw(gcw);
Solution 1:[1]
You can invoke draw(..)
on the object returned by the constructor without assigning it to a variable. You are still creating an object - you just aren't assigning it to a variable so you can access it elsewhere.
new Rectangle(10 * iFrame, 10 * iFrame, 50, 50).draw(gcw);
new Circle(200, 300 - iFrame*5, 100).draw(gcw);
new Ellipse(150, 300, 90 + iFrame, 160).draw(gcw);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vsfDawg |