Skip to content

Instantly share code, notes, and snippets.

@SproutSeeds
Created May 2, 2019 00:33
Show Gist options
  • Save SproutSeeds/31772f21cb6d881ea55bbbe8e14e132b to your computer and use it in GitHub Desktop.
Save SproutSeeds/31772f21cb6d881ea55bbbe8e14e132b to your computer and use it in GitHub Desktop.
Order
public class Order {
public static final double CAPPUCCINO_COST = 3.95;
public static final double ESPRESSO_COST = 1.45;
public static final double BAGEL_COST = 1.25;
public static final double MUFFIN_COST = 1.95;
int cappuccinoCount;
int espressoCount;
int bagelCount;
int muffinCount;
public Order() {
cappuccinoCount = 0;
espressoCount = 0;
bagelCount = 0;
muffinCount = 0;
}
public Order(int cappuccinoCount, int espressoCount, int bagelCount, int muffinCount) {
this.cappuccinoCount = cappuccinoCount;
this.espressoCount = espressoCount;
this.bagelCount = bagelCount;
this.muffinCount = muffinCount;
}
public int getCappuccinoCount() {
return this.cappuccinoCount;
}
public int getEspressoCount() {
return this.espressoCount;
}
public int getBagelCount() {
return this.bagelCount;
}
public int getMuffinCount() {
return this.muffinCount;
}
public double calculateTotal() {
return ((this.cappuccinoCount * CAPPUCCINO_COST) + (this.espressoCount * ESPRESSO_COST)
+ (this.bagelCount * BAGEL_COST) + (this.muffinCount * MUFFIN_COST));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment