You will create Cart class as a context class to get total price and add product.
◦ To implement Strategy pattern, depending on the country of shipping, the relevant customs duty is charged and the shipping cost of Europe Shopping, America Shopping increases. Large products (XL-size) have an additional charge. Create AmericaShopping and EuropeShopping concrete class.
◦In the USA, the duty tax is 1% and the base delivery fee is $15. In America, an additional tax different from the customs tax is applied and this tax is 0.75%. Customs duty should be added to the item fee for each item.
◦In Europe, the customs duty is 1.5% and the base delivery fee is £11.
◦In America, $5 should be added to the shipping fee when each item is added. But if the added product size is XL, $10 should be added to the shipping fee. In Europe, this should only be done if the product size is XL.
public class Main
{
public static void main(String[] args) {
AmericaShopping a=new AmericaShopping();
a.print();
EuropeShopping e=new EuropeShopping();
e.print();
}
}
class Cart{
}
class AmericaShopping{
double duty_tax=0.01;
double base_delivery_fee=15;
double add_tax=0.0075;
double add_shipping_fee_sm=5;
double add_shipping_fee_xl=10;
public void print(){
double total=0.01+15+0.0075+5+10;
System.out.println("Total tax = "+total);
}
}
class EuropeShopping{
double duty_tax=0.015;
double base_delivery_fee=11;
double add_shipping_fee_xl=10;
public void print(){
double total=0.015+11+10;
System.out.println("Total tax = "+total);
}
}
Comments
Leave a comment