@Test public void calculateShippingTest() { Assert.assertEquals(0, shoppingCart.getShippingTotal(), 0); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(2.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(0.01); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(2.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(24.99); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(2.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(25.00); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(4.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(49.99); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(4.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(50.00); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(6.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(74.99); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(6.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(75.00); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(8.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(99.99); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(8.99, shoppingCart.getShippingTotal(), 0); shoppingCart.setCartItemTotal(100.00); shippingService.calculateShipping(shoppingCart); Assert.assertEquals(10.99, shoppingCart.getShippingTotal(), 0); }
public void calculateShipping(ShoppingCart sc) { if ( sc != null ) { if ( sc.getCartItemTotal() >= 0 && sc.getCartItemTotal() < 25) { sc.setShippingTotal(2.99); } else if ( sc.getCartItemTotal() >= 25 && sc.getCartItemTotal() < 50) { sc.setShippingTotal(4.99); } else if ( sc.getCartItemTotal() >= 50 && sc.getCartItemTotal() < 75) { sc.setShippingTotal(6.99); } else if ( sc.getCartItemTotal() >= 75 && sc.getCartItemTotal() < 100) { sc.setShippingTotal(8.99); } else if ( sc.getCartItemTotal() >= 100 && sc.getCartItemTotal() < 10000) { sc.setShippingTotal(10.99); } } }
ShippingService { public void calculateShipping(ShoppingCart sc) { if ( sc != null ) { if ( sc.getCartItemTotal() >= 0 && sc.getCartItemTotal() < 25) { sc.setShippingTotal(2.99); } else if ( sc.getCartItemTotal() >= 25 && sc.getCartItemTotal() < 50) { sc.setShippingTotal(4.99); } else if ( sc.getCartItemTotal() >= 50 && sc.getCartItemTotal() < 75) { sc.setShippingTotal(6.99); } else if ( sc.getCartItemTotal() >= 75 && sc.getCartItemTotal() < 100) { sc.setShippingTotal(8.99); } else if ( sc.getCartItemTotal() >= 100 && sc.getCartItemTotal() < 10000) { sc.setShippingTotal(10.99); } } } }
ShippingService { public void calculateShipping(ShoppingCart sc) { if ( sc != null ) { if ( sc.getCartItemTotal() >= 0 && sc.getCartItemTotal() < 25) { sc.setShippingTotal(2.99); } else if ( sc.getCartItemTotal() >= 25 && sc.getCartItemTotal() < 50) { sc.setShippingTotal(4.99); } else if ( sc.getCartItemTotal() >= 50 && sc.getCartItemTotal() < 75) { sc.setShippingTotal(6.99); } else if ( sc.getCartItemTotal() >= 75 && sc.getCartItemTotal() < 100) { sc.setShippingTotal(8.99); } else if ( sc.getCartItemTotal() >= 100 && sc.getCartItemTotal() < 10000) { sc.setShippingTotal(10.99); } } }  }
ShippingService { public void calculateShipping(ShoppingCart sc) { if ( sc != null ) { if ( sc.getCartItemTotal() >= 0 && sc.getCartItemTotal() < 25) { sc.setShippingTotal(2.99); } else if ( sc.getCartItemTotal() >= 25 && sc.getCartItemTotal() < 50) { sc.setShippingTotal(4.99); } else if ( sc.getCartItemTotal() >= 50 && sc.getCartItemTotal() < 75) { sc.setShippingTotal(6.99); } else if ( sc.getCartItemTotal() >= 75 && sc.getCartItemTotal() < 100) { sc.setShippingTotal(8.99); } else if ( sc.getCartItemTotal() >= 100 && sc.getCartItemTotal() < 10000) { sc.setShippingTotal(10.99); } } }  void calculateShipping(ShoppingCart sc); }
ShippingService { public void calculateShipping(ShoppingCart sc) { if ( sc != null ) { if ( sc.getCartItemTotal() >= 0 && sc.getCartItemTotal() < 25) { sc.setShippingTotal(2.99); } else if ( sc.getCartItemTotal() >= 25 && sc.getCartItemTotal() < 50) { sc.setShippingTotal(4.99); } else if ( sc.getCartItemTotal() >= 50 && sc.getCartItemTotal() < 75) { sc.setShippingTotal(6.99); } else if ( sc.getCartItemTotal() >= 75 && sc.getCartItemTotal() < 100) { sc.setShippingTotal(8.99); } else if ( sc.getCartItemTotal() >= 100 && sc.getCartItemTotal() < 10000) { sc.setShippingTotal(10.99); } } }  void calculateShipping(ShoppingCart sc);  }