Code-part2.zip

Code-part4/Product.java

Code-part4/Product.java

public class Product {
  public String name;
  public int futuristicness;
  public int practicality;

  public Product(String theName, int theFuturisticness, int thePracticality) {
    name=theName; futuristicness=theFuturisticness; practicality=thePracticality;
  }
}

__MACOSX/Code-part4/._Product.java

Code-part4/ChoiceStrategy.java

Code-part4/ChoiceStrategy.java

public interface ChoiceStrategy {
  public Product chooseBetween(Product a, Product b);
}

__MACOSX/Code-part4/._ChoiceStrategy.java

Code-part4/MostFuturisticStrategy.java

Code-part4/MostFuturisticStrategy.java

public class MostFuturisticStrategy implements ChoiceStrategy {
     // Complete this with an implementation of
    // chooseBetween(Product a, Product b) which returns
    // Product a if its futuristicness is greater than or equal
    // to that of b; and returns Product b otherwise
}


__MACOSX/Code-part4/._MostFuturisticStrategy.java

Code-part4/ProductRecommender.java

Code-part4/ProductRecommender.java

public class ProductRecommender {
  ChoiceStrategy myStrategy;

  public static void main(String args[]) {
    ProductRecommender recommender=new ProductRecommender();
    recommender.doExample();
  }

  public void doExample() {
    Product p1=new Product("DeLorean DMC-12", 5, 1);
    Product p2=new Product("LDV Maxus", 1, 5);

     System.out.println("Current strategy: choose most futuristic");
     // Add code here to create a MostFuturisticStrategy and
     // print out the chosen vehicle according to this strategy

        System.out.println("Strategy changed: choose most practical");
    // Add code here to create a MostPracticalStrategy and
    // print out the chosen vehicle according to this strategy

  }
}

__MACOSX/Code-part4/._ProductRecommender.java

Code-part4/MostPracticalStrategy.java

Code-part4/MostPracticalStrategy.java

public class MostPracticalStrategy implements ChoiceStrategy {
    // Complete this with an implementation of
    // chooseBetween(Product a, Product b) which returns
    // Product a if its practicality is greater than or equal
    // to that of b; and returns Product b otherwise
}
   

__MACOSX/Code-part4/._MostPracticalStrategy.java