Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of interface GeometricShape here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. public interface GeometricShape
  9. {
  10.     double area();
  11. }
  12. /**
  13.  * Models a parallelagram in 2-d space
  14.  */
  15.  
  16. public class Parallelogram
  17. {
  18.    
  19.     private int width;
  20.     private int height;
  21.  
  22.     /**
  23.      * Constructor for objects of class Parallelogram
  24.      * @param width the width of this parallelagram
  25.      * @param height the height of this parallelogram
  26.      */
  27.     public Parallelogram(int width, int height)
  28.     {
  29.         this.width = width;
  30.         this.height = height;
  31.     }
  32.    
  33.     /**
  34.      * Gets the width of this Parallelogram
  35.      * @return the width of the parallelogram
  36.      */
  37.     public int getWidth()
  38.     {
  39.         return width;
  40.     }
  41.    
  42.     /**
  43.      * Sets the width of the Parallelogram
  44.      * @param newWidth the value of the new width
  45.      */
  46.     public void setWidth(int newWidth)
  47.     {
  48.         width = newWidth;
  49.     }
  50.    
  51.     /**
  52.      * Gets the height of this Parallelogram
  53.      * @return the height of the parallelogram
  54.      */
  55.     public int getHeight()
  56.     {
  57.         return height;
  58.     }
  59.    
  60.     /**
  61.      * Sets the height of the Parallelogram
  62.      * @param newHeight the value of the new height
  63.      */
  64.     public void setHeight(int newHeight)
  65.     {
  66.         height = newHeight;
  67.     }
  68.      /**
  69.      * Gets the area of a RightTriangle
  70.      * @return the area of a RightTriangle
  71.      */
  72.     public double area()
  73.     {
  74.         double area = width * height;
  75.         return area;
  76.     }
  77.      
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement