Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 11, 2020 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/a8b2e25f71cb5b60c8cd51cc4060b6f5 to your computer and use it in GitHub Desktop.
Save codecademydev/a8b2e25f71cb5b60c8cd51cc4060b6f5 to your computer and use it in GitHub Desktop.
Codecademy export
public class Order {
boolean isFilled;
double billAmount;
String shipping;
public Order(boolean filled, double cost, String shippingMethod) {
isFilled = filled;
billAmount = cost;
shipping = shippingMethod;
}
public void ship() {
if (billAmount > 24.00) {
System.out.println("High value item!");
}
if (isFilled) {
System.out.println("Shipping");
System.out.println("Shipping cost: " + calculateShipping());
} else {
System.out.println("Order not ready");
}
}
public double calculateShipping() {
// declare conditional statement here
if (shipping.equals("Regular")) {
return 0;
} else if (shipping.equals("Express")) {
return 1.75;
} else {
return 0.50;
}
}
public static void main(String[] args) {
// do not alter the main method!
Order book = new Order(true, 9.99, "Express");
Order chemistrySet = new Order(false, 72.50, "Regular");
book.ship();
chemistrySet.ship();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment