Advertisement
yangb

Unit 9 Exercises 10, 13, 14, & 15

Feb 8th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. //-----DISCOUNT BILL-----\\
  2.  
  3.  
  4. public class DiscountBill extends GroceryBill
  5. {
  6.     private int numOfDiscount;
  7.     private double DiscountPrice;
  8.     private double discountPercent;
  9.    
  10.    
  11.     public DiscoutBill(Employee clerk, boolean preferred) {
  12.         super(clerk);
  13.     }
  14.    
  15.     public int getDiscoutCount() {
  16.         return numOfDiscount;
  17.     }
  18.    
  19.     public double getDiscountAmount() {
  20.         return DiscountPrice;
  21.     }
  22.    
  23.     public double getDiscountPercent() {
  24.         return discountPercent;
  25.     }
  26. }
  27.  
  28.  
  29. //-----CASH-----\\
  30.  
  31.  
  32. public class Cash
  33. {
  34.     //CASH CODE NOT PROVIDED... WILL JUST PUT THE EQUALS METHOD!
  35.     private int amount;
  36.    
  37.     public boolean equals (int addAmount) {
  38.         return amount == addAmount;
  39.     }
  40. }
  41.  
  42.  
  43. //-----RECTANGLE-----\\
  44.  
  45.  
  46. public class Rectangle
  47. {
  48.     //DO NOT HAVE REACTANGLE CLASS... WILL JUST PUT EQUALS METHOD!
  49.    
  50.     private int width;
  51.     private int height;
  52.    
  53.     public boolean equals (int oWidth, int oHeight) {
  54.         return width == oWidth && height == oHeight;
  55.     }
  56. }
  57.  
  58.  
  59. //-----TRIANGLE-----\\
  60.  
  61.  
  62. public class Triangle
  63. {
  64.     //DO NOT HAVE TRIANGLE CLASS... WILL JUST PUT EQUALS METHOD!
  65.    
  66.     private int base;
  67.     private int height;
  68.    
  69.     public boolean equals (int oBase, int oHeight) {
  70.         return base == oBase && height == oHeight;
  71.     }
  72. }
  73.  
  74.  
  75. //-----CIRCLE-----\\
  76.  
  77.  
  78. public class Circle
  79. {
  80.     //DO NOT HAVE CIRCLE CLASS... WILL JUST PUT EQUALS METHOD!
  81.    
  82.     private int radius;
  83.    
  84.     public boolean equals (int oRadius) {
  85.         return radius == oRadius;
  86.     }
  87. }
  88.  
  89.  
  90. //-----OCTAGON-----\\
  91.  
  92.  
  93. public class Octagon extends Shape
  94. {
  95.     //DONT HAVE SHAPE SUPERCLASS SO DONT KNOW WHAT TO INCLUDE... WILL GUESSTIMATE.
  96.  
  97.     private int side;
  98.     private double area;
  99.    
  100.     public Octagon (int sideLength)
  101.     {
  102.         side = sideLength;
  103.     }
  104.    
  105.     public int getLength() {
  106.         return side;
  107.     }
  108.    
  109.     public int getPerimeter()
  110.     {
  111.         return side*8;
  112.     }
  113.    
  114.     public double getArea()
  115.     {
  116.         return area;
  117.     }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement