Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an expand() method for java?

Tags:

java

This is just a general question! For an assignment my teacher gave, she worded this as "Almost all shapes are Expandable, meaning all dimensions can be increased by a (multiplicative) factor such as 2 (which would make the shape twice as large in all directions) by invoking method expand()." I tried googling the expand() method and couldn't really find anything so I was wondering, is there an expand method that is the in the object class that everything can use? Or do I have to make one myself?

like image 918
user2762979 Avatar asked Feb 14 '26 15:02

user2762979


1 Answers

No, there is no expand( method in the Object class, as it semantically isn't useful for (almost) all objects. Imagine trying to expand( a socket or write binary data to a hexagon, for example. In addition expand may mean different things. For a shape, one thing. For compressed binary data, another.

You may look into creating your own method(as an instance method of your shape class) or via something more advanced like AffineTransform that can be applied to java.awt.geom shape classes.

Edit after re-read: Your teacher may have created a class for you to use. Or, being an assignment, making an expandable shape is your goal.

like image 60
nanofarad Avatar answered Feb 17 '26 04:02

nanofarad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!