Advertisement
Flaron

Udemy_31. WallArea

Sep 19th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Wall {
  4.  
  5. private double width;
  6. private double height;
  7.  
  8. public double getWidth() {
  9. return width;
  10. }
  11.  
  12. public void setWidth(double width) {
  13. if(width<0)
  14. this.width = 0;
  15. else
  16. this.width=width;
  17. }
  18.  
  19. public double getHeight() {
  20. return height;
  21. }
  22.  
  23. public void setHeight(double height) {
  24. if (height<0)
  25. this.height=0;
  26. else
  27. this.height = height;
  28. }
  29.  
  30. public Wall() {
  31. }
  32.  
  33. public Wall(double width, double height){
  34. setHeight(height);
  35. setWidth(width);
  36. }
  37.  
  38. public double getArea() {
  39. return height*width;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement