Advertisement
Guest User

Shape

a guest
Jun 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. interface Shape {
  2. void resize(Bounds bounds);
  3. void scale(int percent);
  4. }
  5.  
  6. class Rectangle implements Shape {
  7. private int width, height;
  8.  
  9. public void resize(Bounds bounds) {
  10. width = bounds.getWidth();
  11. height = bounds.getHeight();
  12. }
  13.  
  14. public void scale(int percent) {
  15. width *= percent;
  16. height *= percent;
  17. }
  18. }
  19.  
  20. class Circle implements Shape {
  21. public void resize(Bounds bounds) {
  22. radius = bounds.getRadius();
  23. }
  24.  
  25. public void scale(int percent) {
  26. radius *= percent;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement