Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10.
- public class DiscountBill extends GroceryBill
- {
- private boolean preferred;
- private int numDiscountedItems;
- private double discountAmount;
- private double total;
- private double discountPercent;
- public DiscountBill(Employee name, boolean pref)
- {
- super(name);
- preferred = pref;
- }
- public int getDiscountCount()
- {
- for(int i = 0; i < itemsInGroceryList.size(); i++)
- {
- if(itemsInGroceryList.get(i).getDiscount() > 0)
- {
- numDiscountedItems++;
- }
- }
- return numDiscountedItems;
- }
- public double getDiscountAmount()
- {
- for(int i = 0; i < itemsInGroceryList.size(); i++)
- {
- if(itemsInGroceryList.get(i).getDiscount() > 0)
- {
- discountAmount = discountAmount + itemsInGroceryList.get(i).getDiscount();
- }
- }
- return discountAmount;
- }
- public double getTotal()
- {
- if(isPreferredShopper == true)
- {
- total = super.getTotal() - discountAmount;
- return total;
- }
- else{
- total = super.getTotal();
- return total;
- }
- }
- public double getDiscountPercent(){
- discountPercent = (1 - (total/super.getTotal())) * 100;
- return discountPercent;
- }
- }
- 15.
- Public class Octagon implements Shape
- {
- private double length;
- public Rectangle(double iniLength)
- {
- length = iniLength;
- }
- public double getArea()
- {
- return 2*(1+Math.sqrt(2))*length*length;
- }
- public double getPerimeter()
- {
- return 8*length;
- }
- }
- 14.
- Public boolean Equals(Rectangle A)
- {
- if (width = A.width && height = A.height)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- Public boolean Equals(Circle A)
- {
- if (radius = A.radius)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- Public boolean Equals(Triangle pass)
- {
- if (a = pass.a && b = pass.b && c = pass.c)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- 13.
- Public boolean Equals(Cash A)
- {
- if (amount = A.amount)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment