svephoto

PizzaCalories: class Dough [Java]

Apr 10th, 2021
717
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pizzacalories;
  2.  
  3. public class Dough {
  4.     private String flourType;
  5.     private String bakingTechnique;
  6.     private double weight;
  7.  
  8.     public Dough(String flourType, String bakingTechnique, double weight) {
  9.         this.setFlourType(flourType);
  10.         this.setBakingTechnique(bakingTechnique);
  11.         this.setWeight(weight);
  12.     }
  13.  
  14.     private void setFlourType(String flourType) {
  15.         ValidatorUtil.validateFlourType(flourType);
  16.         this.flourType = flourType;
  17.     }
  18.  
  19.     private void setBakingTechnique(String bakingTechnique) {
  20.         ValidatorUtil.validateBakingTechnique(bakingTechnique);
  21.         this.bakingTechnique = bakingTechnique;
  22.     }
  23.  
  24.     private void setWeight(double weight) {
  25.         ValidatorUtil.validateDoughWeight(weight);
  26.         this.weight = weight;
  27.     }
  28.  
  29.     public double calculateCalories() {
  30.         double calories = this.weight * 2;
  31.  
  32.         if ("White".equalsIgnoreCase(this.flourType)) {
  33.             calories *= 1.5;
  34.         }
  35.  
  36.         if ("Crispy".equalsIgnoreCase(this.bakingTechnique)) {
  37.             calories *= 0.9;
  38.         } else if ("Chewy".equalsIgnoreCase(this.bakingTechnique)) {
  39.             calories *= 1.1;
  40.         }
  41.  
  42.         return calories;
  43.     }
  44. }
  45.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×