desislava_topuzakova

1. Rectangle

Jun 4th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class Rectangle {
  2. private double length;
  3. private double width;
  4. private String name;
  5.  
  6. public Rectangle(double length, double width, String name){
  7. this.length = length;
  8. this.width = width;
  9. this.name = name;
  10. }
  11.  
  12. public double radius() {
  13. return 0.5 * Math.sqrt(length * length + width * width);
  14. }
  15.  
  16. public void resize (double x ,double y) {
  17. this.width = width * y;
  18. this.length = length * x;
  19. }
  20.  
  21. public String toString() {
  22. return String.format("Rectangle %s, width: %f, length: %f", this.name, this.width, this.length);
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment